Skip to content

Conversation

@tomershafir
Copy link
Contributor

@tomershafir tomershafir commented Nov 4, 2025

Currently, the ARM backend incorrectly parses every arm prefixed arch to be non-thumb, but armv6m is THUMB and doesnt have ARM ops causing the test to fail when compiling to assembly and not LLVM IR: error: Function 'foo' uses ARM instructions, but the target does not support ARM mode execution. This only happens when invoking cc1 directly and not the Clang driver.

As a quick triage, this patch changes the tests to use thumb.

Uncovered by #151404

@tomershafir tomershafir requested a review from fhahn November 4, 2025 19:15
@tomershafir tomershafir marked this pull request as ready for review November 4, 2025 20:24
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Nov 4, 2025
@llvmbot
Copy link
Member

llvmbot commented Nov 4, 2025

@llvm/pr-subscribers-clang

Author: Tomer Shafir (tomershafir)

Changes

Currently, the ARM backend incorrectly parses every arm prefixed arch to be non-thumb, but armv6m is THUMB and doesnt have ARM ops causing the test to fail: error: Function 'foo' uses ARM instructions, but the target does not support ARM mode execution.

As a quick triage, this change switches the test to use thumb.

Uncovered by #151404


Full diff: https://github.com/llvm/llvm-project/pull/166416.diff

1 Files Affected:

  • (modified) clang/test/CodeGen/pr45476.cpp (+1-1)
diff --git a/clang/test/CodeGen/pr45476.cpp b/clang/test/CodeGen/pr45476.cpp
index c95f7fb8cd9c3..3a67904a8e568 100644
--- a/clang/test/CodeGen/pr45476.cpp
+++ b/clang/test/CodeGen/pr45476.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple armv6m-eabi -emit-llvm %s -o - | FileCheck -check-prefix=LIBCALL %s
+// RUN: %clang_cc1 -triple thumbv6m-eabi -emit-llvm %s -o - | FileCheck -check-prefix=LIBCALL %s
 // RUN: %clang_cc1 -triple armv8-eabi -emit-llvm %s -o - | FileCheck -check-prefix=NATIVE %s
 // PR45476
 

Copy link
Collaborator

@efriedma-quic efriedma-quic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused what, exactly, this is fixing.

We're explicitly specifying the triple, so the host triple shouldn't matter. And this test is currently passing on every buildbot. So what does this do?

@statham-arm
Copy link
Collaborator

We're explicitly specifying the triple, so the host triple shouldn't matter. And this test is currently passing on every buildbot. So what does this do?

It's true that the test passes, because it only goes as far as LLVM IR, compiling the affected test file using -emit-llvm. But if I try going all the way to assembly, by replacing -emit-llvm with -S, then I do see the error:

$ build/bin/clang -cc1 -triple armv6m-eabi clang/test/CodeGen/pr45476.cpp -S -o /dev/null
error: Function 'foo' uses ARM instructions, but the target does not support ARM mode execution.
1 error generated.

If you run the clang driver, rather than clang -cc1, then there's no problem compiling this file to Armv6-M assembler, and of course it comes out in Thumb. But the -v output from the driver command below shows that that's because the driver has converted the triple into a Thumb one, passing -triple thumbv6m-unknown-none-eabi to the clang -cc1 command.

build/bin/clang -v --target=arm-none-eabi -march=armv6m clang/test/CodeGen/pr45476.cpp -S -o /dev/null

So I agree that it looks as if clang -cc1 is expecting to receive a triple that already states the right one of Arm and Thumb, and the handwritten clang -cc1 -triple armv6m-eabi in this test is a bit strange, even if it's not causing this -emit-llvm test to fail.

@statham-arm
Copy link
Collaborator

In a quick grep of the clang tests I can see a total of 9 cases where %clang_cc1 is given a triple of the form armv6m, armv7m or armv8m, compared to over 80 cases of thumbv[678]m.

@tomershafir, if you want to fix all 9 of those instead of just one, on the basis that that way the direct cc1 invocations more closely match what the driver would have done, I'd approve it.

Currently, the ARM backend incorrectly parses every `arm` prefixed arch to be non-thumb, but `armv6m` is THUMB and doesnt have ARM ops causing the test to fail when compiling to assembly and not LLVM IR: `error: Function 'foo' uses ARM instructions, but the target does not support ARM mode execution.` This only happens when invoking cc1 directly and not the Clang driver.

As a quick triage, this patch changes the tests to use `thumb`.

Uncovered by llvm#151404
@tomershafir tomershafir force-pushed the arm-fix-test-use-thumb-arch-prefix-not-arm branch from 8d3b939 to f7a407e Compare November 5, 2025 13:28
@tomershafir tomershafir changed the title [ARM] Fix test using thumb instead arm arch prefix [Clang][ARM] Fix tests using thumb instead arm arch on cc1 Nov 5, 2025
@tomershafir tomershafir merged commit 5fedb7c into llvm:main Nov 5, 2025
10 checks passed
@tomershafir tomershafir deleted the arm-fix-test-use-thumb-arch-prefix-not-arm branch November 5, 2025 14:29
@llvm-ci
Copy link
Collaborator

llvm-ci commented Nov 5, 2025

LLVM Buildbot has detected a new failure on builder ppc64le-lld-multistage-test running on ppc64le-lld-multistage-test while building clang at step 12 "build-stage2-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/168/builds/16884

Here is the relevant piece of the build log for the reference
Step 12 (build-stage2-unified-tree) failure: build (failure) (timed out)
...
1179.186 [57/10/6701] Linking CXX executable bin/lld
1179.284 [57/9/6702] Linking CXX executable tools/lld/unittests/AsLibAll/LLDAsLibAllTests
1179.346 [57/8/6703] Linking CXX executable unittests/MIR/MIRTests
1179.586 [57/7/6704] Linking CXX executable unittests/CodeGen/CGPluginTest/CGPluginTest
1180.336 [57/6/6705] Linking CXX executable bin/llvm-opt-fuzzer
1180.425 [57/5/6706] Linking CXX executable bin/dsymutil
1180.489 [57/4/6707] Linking CXX executable bin/llvm-isel-fuzzer
1180.798 [57/3/6708] Linking CXX executable unittests/CodeGen/CodeGenTests
1218.197 [57/2/6709] Building CXX object tools/bugpoint-passes/CMakeFiles/BugpointPasses.dir/TestPasses.cpp.o
1218.813 [56/2/6710] Linking CXX shared module lib/BugpointPasses.so
command timed out: 1200 seconds without output running [b'ninja'], attempting to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=2419.409714

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants