Skip to content

clang: Emit "target-abi" module flag for ARM - #217601

Merged
arsenm merged 1 commit into
mainfrom
users/arsenm/target-abi-clang-emit
Aug 20, 2026
Merged

arsenm merged 1 commit into
mainfrom
users/arsenm/target-abi-clang-emit

Conversation

@arsenm

@arsenm arsenm commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Previously only RISCV emitted the "target-abi" module flag.
We probably should just generally emit this for non-empty ABI names
but that's a broader behavior change. I'm also confused because the
clang side defines a non-empty value for many targets with no apparent
use in llvm.

Co-authored-by: Claude (Claude-Opus-4.8) [email protected]

arsenm commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor Author

@llvmorg-github-actions

llvmorg-github-actions Bot commented Aug 20, 2026 •

Copy link
Copy Markdown

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-backend-arm

Author: Matt Arsenault (arsenm)

Changes

Previously only RISCV emitted the "target-abi" module flag.
We probably should just generally emit this for non-empty ABI names
but that's a broader behavior change. I'm also confused because the
clang side defines a non-empty value for many targets with no apparent
use in llvm.

Co-authored-by: Claude (Claude-Opus-4.8) <[email protected]>


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

2 Files Affected:

  • (modified) clang/lib/CodeGen/CodeGenModule.cpp (+11-3)
  • (added) clang/test/CodeGen/arm-target-abi-module-flag.c (+19)
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index d348e80780ee9..50901fe388140 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1472,6 +1472,17 @@ void CodeGenModule::Release() {
   }
 
   llvm::Triple T = Context.getTargetInfo().getTriple();
+
+  // TODO: This should probably be just generally emitted for non-empty ABI
+  // names. LoongArch actively consumes the flag, but it is excluded here.
+  // Other targets have no apparent need for the ABI name, but set a non-empty
+  // value.
+  if (StringRef ABIStr = Target.getABI();
+      !ABIStr.empty() && (T.isARM() || T.isThumb() || T.isRISCV())) {
+    getModule().addModuleFlag(llvm::Module::Error, "target-abi",
+                              llvm::MDString::get(VMContext, ABIStr));
+  }
+
   if (T.isARM() || T.isThumb()) {
     // The minimum width of an enum in bytes
     uint32_t EnumWidth = Context.getLangOpts().ShortEnums ? 1 : 4;
@@ -1479,10 +1490,7 @@ void CodeGenModule::Release() {
   }
 
   if (T.isRISCV()) {
-    StringRef ABIStr = Target.getABI();
     llvm::LLVMContext &Ctx = TheModule.getContext();
-    getModule().addModuleFlag(llvm::Module::Error, "target-abi",
-                              llvm::MDString::get(Ctx, ABIStr));
 
     // Add the canonical ISA string as metadata so the backend can set the ELF
     // attributes correctly. We use AppendUnique so LTO will keep all of the
diff --git a/clang/test/CodeGen/arm-target-abi-module-flag.c b/clang/test/CodeGen/arm-target-abi-module-flag.c
new file mode 100644
index 0000000000000..9707372b2a3fd
--- /dev/null
+++ b/clang/test/CodeGen/arm-target-abi-module-flag.c
@@ -0,0 +1,19 @@
+// Check that clang emits the "target-abi" module flag for ARM/Thumb using the
+// target ABI string.
+
+// Default ABIs (no -target-abi override).
+// RUN: %clang_cc1 -triple armv7-linux-gnueabihf -emit-llvm -o - %s | FileCheck --check-prefix=AAPCS-LINUX %s
+// RUN: %clang_cc1 -triple armv7-none-eabi -emit-llvm -o - %s | FileCheck --check-prefix=AAPCS %s
+// RUN: %clang_cc1 -triple armv7-apple-darwin -emit-llvm -o - %s | FileCheck --check-prefix=APCS-GNU %s
+// RUN: %clang_cc1 -triple armv7k-apple-watchos -emit-llvm -o - %s | FileCheck --check-prefix=AAPCS16 %s
+// RUN: %clang_cc1 -triple thumbv7-linux-gnueabihf -emit-llvm -o - %s | FileCheck --check-prefix=AAPCS-LINUX %s
+
+// Explicit -target-abi override differing from the triple default.
+// RUN: %clang_cc1 -triple armv7-linux-gnueabihf -target-abi apcs-gnu -emit-llvm -o - %s | FileCheck --check-prefix=APCS-GNU %s
+
+// AAPCS-LINUX: !{i32 1, !"target-abi", !"aapcs-linux"}
+// AAPCS: !{i32 1, !"target-abi", !"aapcs"}
+// APCS-GNU: !{i32 1, !"target-abi", !"apcs-gnu"}
+// AAPCS16: !{i32 1, !"target-abi", !"aapcs16"}
+
+int x;

@llvmorg-github-actions llvmorg-github-actions Bot added clang Clang issues not falling into any other category clang:codegen IR generation bugs: mangling, exceptions, etc. labels Aug 20, 2026
@arsenm
arsenm requested review from RKSimon and phoebewang August 20, 2026 12:22
@github-actions

github-actions Bot commented Aug 20, 2026 •

Copy link
Copy Markdown

🐧 Linux x64 Test Results

  • 90952 tests passed
  • 1811 tests skipped
  • 2 tests failed

Failed Tests

(click on a test name to see its output)

Clang

Clang.CodeGen/ubsan-function-sugared.cpp
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/24/include -nostdsysteminc -triple x86_64-linux-gnu -emit-llvm -o - /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function-sugared.cpp -fsanitize=function -fno-sanitize-recover=all | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function-sugared.cpp --check-prefixes=CHECK,GNU,64
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/24/include -nostdsysteminc -triple x86_64-linux-gnu -emit-llvm -o - /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function-sugared.cpp -fsanitize=function -fno-sanitize-recover=all
# note: command had no output on stdout or stderr
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function-sugared.cpp --check-prefixes=CHECK,GNU,64
# note: command had no output on stdout or stderr
# RUN: at line 2
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/24/include -nostdsysteminc -triple x86_64-pc-windows-msvc -emit-llvm -o - /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function-sugared.cpp -fsanitize=function -fno-sanitize-recover=all | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function-sugared.cpp --check-prefixes=CHECK,MSVC,64
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/24/include -nostdsysteminc -triple x86_64-pc-windows-msvc -emit-llvm -o - /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function-sugared.cpp -fsanitize=function -fno-sanitize-recover=all
# note: command had no output on stdout or stderr
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function-sugared.cpp --check-prefixes=CHECK,MSVC,64
# note: command had no output on stdout or stderr
# RUN: at line 3
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/24/include -nostdsysteminc -triple aarch64-linux-gnu -emit-llvm -o - /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function-sugared.cpp -fsanitize=function -fno-sanitize-recover=all | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function-sugared.cpp --check-prefixes=CHECK,GNU,64
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/24/include -nostdsysteminc -triple aarch64-linux-gnu -emit-llvm -o - /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function-sugared.cpp -fsanitize=function -fno-sanitize-recover=all
# note: command had no output on stdout or stderr
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function-sugared.cpp --check-prefixes=CHECK,GNU,64
# note: command had no output on stdout or stderr
# RUN: at line 4
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/24/include -nostdsysteminc -triple aarch64_be-linux-gnu -emit-llvm -o - /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function-sugared.cpp -fsanitize=function -fno-sanitize-recover=all | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function-sugared.cpp --check-prefixes=CHECK,GNU,64
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/24/include -nostdsysteminc -triple aarch64_be-linux-gnu -emit-llvm -o - /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function-sugared.cpp -fsanitize=function -fno-sanitize-recover=all
# note: command had no output on stdout or stderr
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function-sugared.cpp --check-prefixes=CHECK,GNU,64
# note: command had no output on stdout or stderr
# RUN: at line 5
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/24/include -nostdsysteminc -triple arm-none-eabi -emit-llvm -o - /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function-sugared.cpp -fsanitize=function -fno-sanitize-recover=all | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function-sugared.cpp --check-prefixes=CHECK,ARM,GNU,32
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/24/include -nostdsysteminc -triple arm-none-eabi -emit-llvm -o - /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function-sugared.cpp -fsanitize=function -fno-sanitize-recover=all
# note: command had no output on stdout or stderr
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function-sugared.cpp --check-prefixes=CHECK,ARM,GNU,32
# .---command stderr------------
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function-sugared.cpp:13:9: error: ARM: expected string not found in input
# | // ARM: call ptr @llvm.ptrmask.p0.i32(ptr {{.*}}, i32 -2), !nosanitize !5
# |         ^
# | <stdin>:17:36: note: scanning from here
# | define dso_local void @_Z6callerv() #0 !func_sanitize !5 {
# |                                    ^
# | <stdin>:22:7: note: possible intended match here
# |  %1 = call ptr @llvm.ptrmask.p0.i32(ptr %0, i32 -2), !nosanitize !6
# |       ^
# | 
# | Input file: <stdin>
# | Check file: /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function-sugared.cpp
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             .
# |             .
# |             .
# |            12: entry: 
# |            13:  ret void 
# |            14: } 
# |            15:  
# |            16: ; Function Attrs: mustprogress noinline nounwind optnone 
# |            17: define dso_local void @_Z6callerv() #0 !func_sanitize !5 { 
# | check:13'0                                       {                          search range start (exclusive)
# | check:13'1                                                                  error: no match found in search range
# |            18: entry: 
# |            19:  %a = alloca ptr, align 4 
# |            20:  store ptr @_Z3funv, ptr %a, align 4 
# |            21:  %0 = load ptr, ptr %a, align 4 
# |            22:  %1 = call ptr @llvm.ptrmask.p0.i32(ptr %0, i32 -2), !nosanitize !6 
# | check:13'2           ?                                                               possible intended match
# |            23:  %2 = getelementptr <{ i32, i32 }>, ptr %1, i32 -1, i32 0, !nosanitize !6 
# |            24:  %3 = load i32, ptr %2, align 4, !nosanitize !6 
# |            25:  %4 = icmp eq i32 %3, -1056584962, !nosanitize !6 
# |            26:  br i1 %4, label %typecheck, label %cont1, !nosanitize !6 
# |            27:  
# |             .
# |             .
# |             .
# |            63: !2 = !{i32 4, !"arm-eabi-fp-denormal", i32 1} 
# |            64: !3 = !{i32 8, !"arm-eabi-fp-number-model", i32 3} 
# |            65: !4 = !{!"clang version 24.0.0git (https://github.com/llvm/llvm-project 723d47ae6d0e2a2d2eedc5f35b55b389d375498c)"} 
# |            66: !5 = !{i32 -1056584962, i32 905068220} 
# |            67: !6 = !{} 
# |            68: !7 = !{!"branch_weights", i32 1048575, i32 1} 
# | check:13'3                                                   } search range end (exclusive)
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

Clang.CodeGen/ubsan-function.cpp
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/24/include -nostdsysteminc -triple x86_64-linux-gnu -emit-llvm -o - /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function.cpp -fsanitize=function -fno-sanitize-recover=all | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function.cpp --check-prefixes=CHECK,GNU,64
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/24/include -nostdsysteminc -triple x86_64-linux-gnu -emit-llvm -o - /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function.cpp -fsanitize=function -fno-sanitize-recover=all
# note: command had no output on stdout or stderr
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function.cpp --check-prefixes=CHECK,GNU,64
# note: command had no output on stdout or stderr
# RUN: at line 2
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/24/include -nostdsysteminc -triple x86_64-pc-windows-msvc -emit-llvm -o - /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function.cpp -fsanitize=function -fno-sanitize-recover=all | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function.cpp --check-prefixes=CHECK,MSVC,64
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/24/include -nostdsysteminc -triple x86_64-pc-windows-msvc -emit-llvm -o - /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function.cpp -fsanitize=function -fno-sanitize-recover=all
# note: command had no output on stdout or stderr
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function.cpp --check-prefixes=CHECK,MSVC,64
# note: command had no output on stdout or stderr
# RUN: at line 3
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/24/include -nostdsysteminc -triple aarch64-linux-gnu -emit-llvm -o - /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function.cpp -fsanitize=function -fno-sanitize-recover=all | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function.cpp --check-prefixes=CHECK,GNU,64
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/24/include -nostdsysteminc -triple aarch64-linux-gnu -emit-llvm -o - /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function.cpp -fsanitize=function -fno-sanitize-recover=all
# note: command had no output on stdout or stderr
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function.cpp --check-prefixes=CHECK,GNU,64
# note: command had no output on stdout or stderr
# RUN: at line 4
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/24/include -nostdsysteminc -triple aarch64_be-linux-gnu -emit-llvm -o - /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function.cpp -fsanitize=function -fno-sanitize-recover=all | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function.cpp --check-prefixes=CHECK,GNU,64
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/24/include -nostdsysteminc -triple aarch64_be-linux-gnu -emit-llvm -o - /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function.cpp -fsanitize=function -fno-sanitize-recover=all
# note: command had no output on stdout or stderr
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function.cpp --check-prefixes=CHECK,GNU,64
# note: command had no output on stdout or stderr
# RUN: at line 5
/home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/24/include -nostdsysteminc -triple arm-none-eabi -emit-llvm -o - /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function.cpp -fsanitize=function -fno-sanitize-recover=all | /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function.cpp --check-prefixes=CHECK,ARM,GNU,32
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/clang -cc1 -internal-isystem /home/gha/actions-runner/_work/llvm-project/llvm-project/build/lib/clang/24/include -nostdsysteminc -triple arm-none-eabi -emit-llvm -o - /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function.cpp -fsanitize=function -fno-sanitize-recover=all
# note: command had no output on stdout or stderr
# executed command: /home/gha/actions-runner/_work/llvm-project/llvm-project/build/bin/FileCheck /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function.cpp --check-prefixes=CHECK,ARM,GNU,32
# .---command stderr------------
# | /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function.cpp:16:9: error: ARM: expected string not found in input
# | // ARM: call ptr @llvm.ptrmask.p0.i32(ptr {{.*}}, i32 -2), !nosanitize !6
# |         ^
# | <stdin>:17:54: note: scanning from here
# | define dso_local void @_Z6callerPFvvE(ptr noundef %f) #0 !func_sanitize !6 {
# |                                                      ^
# | <stdin>:22:7: note: possible intended match here
# |  %1 = call ptr @llvm.ptrmask.p0.i32(ptr %0, i32 -2), !nosanitize !7
# |       ^
# | 
# | Input file: <stdin>
# | Check file: /home/gha/actions-runner/_work/llvm-project/llvm-project/clang/test/CodeGen/ubsan-function.cpp
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             .
# |             .
# |             .
# |            12: entry: 
# |            13:  ret void 
# |            14: } 
# |            15:  
# |            16: ; Function Attrs: mustprogress noinline nounwind optnone 
# |            17: define dso_local void @_Z6callerPFvvE(ptr noundef %f) #0 !func_sanitize !6 { 
# | check:16'0                                                         {                          search range start (exclusive)
# | check:16'1                                                                                    error: no match found in search range
# |            18: entry: 
# |            19:  %f.addr = alloca ptr, align 4 
# |            20:  store ptr %f, ptr %f.addr, align 4 
# |            21:  %0 = load ptr, ptr %f.addr, align 4 
# |            22:  %1 = call ptr @llvm.ptrmask.p0.i32(ptr %0, i32 -2), !nosanitize !7 
# | check:16'2           ?                                                               possible intended match
# |            23:  %2 = getelementptr <{ i32, i32 }>, ptr %1, i32 -1, i32 0, !nosanitize !7 
# |            24:  %3 = load i32, ptr %2, align 4, !nosanitize !7 
# |            25:  %4 = icmp eq i32 %3, -1056584962, !nosanitize !7 
# |            26:  br i1 %4, label %typecheck, label %cont1, !nosanitize !7 
# |            27:  
# |             .
# |             .
# |             .
# |            55: entry: 
# |            56:  ret void 
# |            57: } 
# |            58:  
# |            59: ; Function Attrs: mustprogress noinline nounwind optnone 
# |            60: define dso_local void @_Z7caller2PFvvE(ptr noundef %f) #0 !func_sanitize !6 { 
# | check:16'3                                                           }                         search range end (exclusive)
# |            61: entry: 
# |            62:  %f.addr = alloca ptr, align 4 
# |            63:  store ptr %f, ptr %f.addr, align 4 
# |            64:  %0 = load ptr, ptr %f.addr, align 4 
# |            65:  call void %0() 
# |             .
# |             .
# |             .
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the infrastructure label.

@github-actions

github-actions Bot commented Aug 20, 2026 •

Copy link
Copy Markdown

🪟 Windows x64 Test Results

  • 56153 tests passed
  • 1524 tests skipped
  • 2 tests failed

Failed Tests

(click on a test name to see its output)

Clang

Clang.CodeGen/ubsan-function-sugared.cpp
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
c:\_work\llvm-project\llvm-project\build\bin\clang.exe -cc1 -internal-isystem C:\_work\llvm-project\llvm-project\build\lib\clang\24\include -nostdsysteminc -triple x86_64-linux-gnu -emit-llvm -o - C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function-sugared.cpp -fsanitize=function -fno-sanitize-recover=all | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function-sugared.cpp --check-prefixes=CHECK,GNU,64
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\clang.exe' -cc1 -internal-isystem 'C:\_work\llvm-project\llvm-project\build\lib\clang\24\include' -nostdsysteminc -triple x86_64-linux-gnu -emit-llvm -o - 'C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function-sugared.cpp' -fsanitize=function -fno-sanitize-recover=all
# note: command had no output on stdout or stderr
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe' 'C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function-sugared.cpp' --check-prefixes=CHECK,GNU,64
# note: command had no output on stdout or stderr
# RUN: at line 2
c:\_work\llvm-project\llvm-project\build\bin\clang.exe -cc1 -internal-isystem C:\_work\llvm-project\llvm-project\build\lib\clang\24\include -nostdsysteminc -triple x86_64-pc-windows-msvc -emit-llvm -o - C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function-sugared.cpp -fsanitize=function -fno-sanitize-recover=all | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function-sugared.cpp --check-prefixes=CHECK,MSVC,64
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\clang.exe' -cc1 -internal-isystem 'C:\_work\llvm-project\llvm-project\build\lib\clang\24\include' -nostdsysteminc -triple x86_64-pc-windows-msvc -emit-llvm -o - 'C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function-sugared.cpp' -fsanitize=function -fno-sanitize-recover=all
# note: command had no output on stdout or stderr
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe' 'C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function-sugared.cpp' --check-prefixes=CHECK,MSVC,64
# note: command had no output on stdout or stderr
# RUN: at line 3
c:\_work\llvm-project\llvm-project\build\bin\clang.exe -cc1 -internal-isystem C:\_work\llvm-project\llvm-project\build\lib\clang\24\include -nostdsysteminc -triple aarch64-linux-gnu -emit-llvm -o - C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function-sugared.cpp -fsanitize=function -fno-sanitize-recover=all | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function-sugared.cpp --check-prefixes=CHECK,GNU,64
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\clang.exe' -cc1 -internal-isystem 'C:\_work\llvm-project\llvm-project\build\lib\clang\24\include' -nostdsysteminc -triple aarch64-linux-gnu -emit-llvm -o - 'C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function-sugared.cpp' -fsanitize=function -fno-sanitize-recover=all
# note: command had no output on stdout or stderr
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe' 'C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function-sugared.cpp' --check-prefixes=CHECK,GNU,64
# note: command had no output on stdout or stderr
# RUN: at line 4
c:\_work\llvm-project\llvm-project\build\bin\clang.exe -cc1 -internal-isystem C:\_work\llvm-project\llvm-project\build\lib\clang\24\include -nostdsysteminc -triple aarch64_be-linux-gnu -emit-llvm -o - C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function-sugared.cpp -fsanitize=function -fno-sanitize-recover=all | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function-sugared.cpp --check-prefixes=CHECK,GNU,64
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\clang.exe' -cc1 -internal-isystem 'C:\_work\llvm-project\llvm-project\build\lib\clang\24\include' -nostdsysteminc -triple aarch64_be-linux-gnu -emit-llvm -o - 'C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function-sugared.cpp' -fsanitize=function -fno-sanitize-recover=all
# note: command had no output on stdout or stderr
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe' 'C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function-sugared.cpp' --check-prefixes=CHECK,GNU,64
# note: command had no output on stdout or stderr
# RUN: at line 5
c:\_work\llvm-project\llvm-project\build\bin\clang.exe -cc1 -internal-isystem C:\_work\llvm-project\llvm-project\build\lib\clang\24\include -nostdsysteminc -triple arm-none-eabi -emit-llvm -o - C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function-sugared.cpp -fsanitize=function -fno-sanitize-recover=all | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function-sugared.cpp --check-prefixes=CHECK,ARM,GNU,32
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\clang.exe' -cc1 -internal-isystem 'C:\_work\llvm-project\llvm-project\build\lib\clang\24\include' -nostdsysteminc -triple arm-none-eabi -emit-llvm -o - 'C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function-sugared.cpp' -fsanitize=function -fno-sanitize-recover=all
# note: command had no output on stdout or stderr
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe' 'C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function-sugared.cpp' --check-prefixes=CHECK,ARM,GNU,32
# .---command stderr------------
# | C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function-sugared.cpp:13:9: error: ARM: expected string not found in input
# | // ARM: call ptr @llvm.ptrmask.p0.i32(ptr {{.*}}, i32 -2), !nosanitize !5
# |         ^
# | <stdin>:17:36: note: scanning from here
# | define dso_local void @_Z6callerv() #0 !func_sanitize !5 {
# |                                    ^
# | <stdin>:22:7: note: possible intended match here
# |  %1 = call ptr @llvm.ptrmask.p0.i32(ptr %0, i32 -2), !nosanitize !6
# |       ^
# | 
# | Input file: <stdin>
# | Check file: C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function-sugared.cpp
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             .
# |             .
# |             .
# |            12: entry: 
# |            13:  ret void 
# |            14: } 
# |            15:  
# |            16: ; Function Attrs: mustprogress noinline nounwind optnone 
# |            17: define dso_local void @_Z6callerv() #0 !func_sanitize !5 { 
# | check:13'0                                       {                          search range start (exclusive)
# | check:13'1                                                                  error: no match found in search range
# |            18: entry: 
# |            19:  %a = alloca ptr, align 4 
# |            20:  store ptr @_Z3funv, ptr %a, align 4 
# |            21:  %0 = load ptr, ptr %a, align 4 
# |            22:  %1 = call ptr @llvm.ptrmask.p0.i32(ptr %0, i32 -2), !nosanitize !6 
# | check:13'2           ?                                                               possible intended match
# |            23:  %2 = getelementptr <{ i32, i32 }>, ptr %1, i32 -1, i32 0, !nosanitize !6 
# |            24:  %3 = load i32, ptr %2, align 4, !nosanitize !6 
# |            25:  %4 = icmp eq i32 %3, -1056584962, !nosanitize !6 
# |            26:  br i1 %4, label %typecheck, label %cont1, !nosanitize !6 
# |            27:  
# |             .
# |             .
# |             .
# |            63: !2 = !{i32 4, !"arm-eabi-fp-denormal", i32 1} 
# |            64: !3 = !{i32 8, !"arm-eabi-fp-number-model", i32 3} 
# |            65: !4 = !{!"clang version 24.0.0git (https://github.com/llvm/llvm-project 723d47ae6d0e2a2d2eedc5f35b55b389d375498c)"} 
# |            66: !5 = !{i32 -1056584962, i32 905068220} 
# |            67: !6 = !{} 
# |            68: !7 = !{!"branch_weights", i32 1048575, i32 1} 
# | check:13'3                                                   } search range end (exclusive)
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

Clang.CodeGen/ubsan-function.cpp
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
c:\_work\llvm-project\llvm-project\build\bin\clang.exe -cc1 -internal-isystem C:\_work\llvm-project\llvm-project\build\lib\clang\24\include -nostdsysteminc -triple x86_64-linux-gnu -emit-llvm -o - C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function.cpp -fsanitize=function -fno-sanitize-recover=all | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function.cpp --check-prefixes=CHECK,GNU,64
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\clang.exe' -cc1 -internal-isystem 'C:\_work\llvm-project\llvm-project\build\lib\clang\24\include' -nostdsysteminc -triple x86_64-linux-gnu -emit-llvm -o - 'C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function.cpp' -fsanitize=function -fno-sanitize-recover=all
# note: command had no output on stdout or stderr
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe' 'C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function.cpp' --check-prefixes=CHECK,GNU,64
# note: command had no output on stdout or stderr
# RUN: at line 2
c:\_work\llvm-project\llvm-project\build\bin\clang.exe -cc1 -internal-isystem C:\_work\llvm-project\llvm-project\build\lib\clang\24\include -nostdsysteminc -triple x86_64-pc-windows-msvc -emit-llvm -o - C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function.cpp -fsanitize=function -fno-sanitize-recover=all | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function.cpp --check-prefixes=CHECK,MSVC,64
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\clang.exe' -cc1 -internal-isystem 'C:\_work\llvm-project\llvm-project\build\lib\clang\24\include' -nostdsysteminc -triple x86_64-pc-windows-msvc -emit-llvm -o - 'C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function.cpp' -fsanitize=function -fno-sanitize-recover=all
# note: command had no output on stdout or stderr
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe' 'C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function.cpp' --check-prefixes=CHECK,MSVC,64
# note: command had no output on stdout or stderr
# RUN: at line 3
c:\_work\llvm-project\llvm-project\build\bin\clang.exe -cc1 -internal-isystem C:\_work\llvm-project\llvm-project\build\lib\clang\24\include -nostdsysteminc -triple aarch64-linux-gnu -emit-llvm -o - C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function.cpp -fsanitize=function -fno-sanitize-recover=all | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function.cpp --check-prefixes=CHECK,GNU,64
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\clang.exe' -cc1 -internal-isystem 'C:\_work\llvm-project\llvm-project\build\lib\clang\24\include' -nostdsysteminc -triple aarch64-linux-gnu -emit-llvm -o - 'C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function.cpp' -fsanitize=function -fno-sanitize-recover=all
# note: command had no output on stdout or stderr
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe' 'C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function.cpp' --check-prefixes=CHECK,GNU,64
# note: command had no output on stdout or stderr
# RUN: at line 4
c:\_work\llvm-project\llvm-project\build\bin\clang.exe -cc1 -internal-isystem C:\_work\llvm-project\llvm-project\build\lib\clang\24\include -nostdsysteminc -triple aarch64_be-linux-gnu -emit-llvm -o - C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function.cpp -fsanitize=function -fno-sanitize-recover=all | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function.cpp --check-prefixes=CHECK,GNU,64
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\clang.exe' -cc1 -internal-isystem 'C:\_work\llvm-project\llvm-project\build\lib\clang\24\include' -nostdsysteminc -triple aarch64_be-linux-gnu -emit-llvm -o - 'C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function.cpp' -fsanitize=function -fno-sanitize-recover=all
# note: command had no output on stdout or stderr
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe' 'C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function.cpp' --check-prefixes=CHECK,GNU,64
# note: command had no output on stdout or stderr
# RUN: at line 5
c:\_work\llvm-project\llvm-project\build\bin\clang.exe -cc1 -internal-isystem C:\_work\llvm-project\llvm-project\build\lib\clang\24\include -nostdsysteminc -triple arm-none-eabi -emit-llvm -o - C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function.cpp -fsanitize=function -fno-sanitize-recover=all | c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function.cpp --check-prefixes=CHECK,ARM,GNU,32
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\clang.exe' -cc1 -internal-isystem 'C:\_work\llvm-project\llvm-project\build\lib\clang\24\include' -nostdsysteminc -triple arm-none-eabi -emit-llvm -o - 'C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function.cpp' -fsanitize=function -fno-sanitize-recover=all
# note: command had no output on stdout or stderr
# executed command: 'c:\_work\llvm-project\llvm-project\build\bin\filecheck.exe' 'C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function.cpp' --check-prefixes=CHECK,ARM,GNU,32
# .---command stderr------------
# | C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function.cpp:16:9: error: ARM: expected string not found in input
# | // ARM: call ptr @llvm.ptrmask.p0.i32(ptr {{.*}}, i32 -2), !nosanitize !6
# |         ^
# | <stdin>:17:54: note: scanning from here
# | define dso_local void @_Z6callerPFvvE(ptr noundef %f) #0 !func_sanitize !6 {
# |                                                      ^
# | <stdin>:22:7: note: possible intended match here
# |  %1 = call ptr @llvm.ptrmask.p0.i32(ptr %0, i32 -2), !nosanitize !7
# |       ^
# | 
# | Input file: <stdin>
# | Check file: C:\_work\llvm-project\llvm-project\clang\test\CodeGen\ubsan-function.cpp
# | 
# | -dump-input=help explains the following input dump.
# | 
# | Input was:
# | <<<<<<
# |             .
# |             .
# |             .
# |            12: entry: 
# |            13:  ret void 
# |            14: } 
# |            15:  
# |            16: ; Function Attrs: mustprogress noinline nounwind optnone 
# |            17: define dso_local void @_Z6callerPFvvE(ptr noundef %f) #0 !func_sanitize !6 { 
# | check:16'0                                                         {                          search range start (exclusive)
# | check:16'1                                                                                    error: no match found in search range
# |            18: entry: 
# |            19:  %f.addr = alloca ptr, align 4 
# |            20:  store ptr %f, ptr %f.addr, align 4 
# |            21:  %0 = load ptr, ptr %f.addr, align 4 
# |            22:  %1 = call ptr @llvm.ptrmask.p0.i32(ptr %0, i32 -2), !nosanitize !7 
# | check:16'2           ?                                                               possible intended match
# |            23:  %2 = getelementptr <{ i32, i32 }>, ptr %1, i32 -1, i32 0, !nosanitize !7 
# |            24:  %3 = load i32, ptr %2, align 4, !nosanitize !7 
# |            25:  %4 = icmp eq i32 %3, -1056584962, !nosanitize !7 
# |            26:  br i1 %4, label %typecheck, label %cont1, !nosanitize !7 
# |            27:  
# |             .
# |             .
# |             .
# |            55: entry: 
# |            56:  ret void 
# |            57: } 
# |            58:  
# |            59: ; Function Attrs: mustprogress noinline nounwind optnone 
# |            60: define dso_local void @_Z7caller2PFvvE(ptr noundef %f) #0 !func_sanitize !6 { 
# | check:16'3                                                           }                         search range end (exclusive)
# |            61: entry: 
# |            62:  %f.addr = alloca ptr, align 4 
# |            63:  store ptr %f, ptr %f.addr, align 4 
# |            64:  %0 = load ptr, ptr %f.addr, align 4 
# |            65:  call void %0() 
# |             .
# |             .
# |             .
# | >>>>>>
# `-----------------------------
# error: command failed with exit status: 1

--

If these failures are unrelated to your changes (for example tests are broken or flaky at HEAD), please open an issue at https://github.com/llvm/llvm-project/issues and add the infrastructure label.

@arsenm
arsenm force-pushed the users/arsenm/target-abi-clang-emit branch from 86fca79 to fbbef72 Compare August 20, 2026 13:19
@arsenm
arsenm force-pushed the users/arsenm/target-abi-arm branch from 011eb21 to 646ea6d Compare August 20, 2026 13:19

@rnk rnk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What is the public interface to reach -target-abi? Testing shows it's a -cc1 flag, and I couldn't find anything in the command line reference.

Anyway, this is a setting you can set in the frontend, so we should encode it in the IR for the backend.

Base automatically changed from users/arsenm/target-abi-arm to main August 20, 2026 15:33
@arsenm

arsenm commented Aug 20, 2026

Copy link
Copy Markdown
Contributor Author

What is the public interface to reach -target-abi? Testing shows it's a -cc1 flag, and I couldn't find anything in the command line reference.

-mabi

Previously only RISCV emitted the "target-abi" module flag.
We probably should just generally emit this for non-empty ABI names
but that's a broader behavior change. I'm also confused because the
clang side defines a non-empty value for many targets with no apparent
use in llvm.

Co-authored-by: Claude (Claude-Opus-4.8) <[email protected]>
@arsenm
arsenm force-pushed the users/arsenm/target-abi-clang-emit branch from fbbef72 to 43f21cb Compare August 20, 2026 15:53
@arsenm
arsenm merged commit 78f210e into main Aug 20, 2026
11 of 12 checks passed
@arsenm
arsenm deleted the users/arsenm/target-abi-clang-emit branch August 20, 2026 17:01
arsenm pushed a commit that referenced this pull request Sep 16, 2026
The LoongArch backend reads the ABI from the "target-abi" module flag,
but clang only emits that flag for ARM, PowerPC and RISC-V. Since LTO code
generation doesn't see the -target-abi option passed to clang, it falls
back to the default ABI of the target, which is lp64d for
loongarch64-unknown-elf, regardless of the ABI the code was compiled for.

When an FPU is enabled, this silently miscompiles code built for another
ABI. For example, with -mabi=lp64s, functions get the lp64d calling
convention after LTO, passing and returning floating-point values in FP registers 
instead of general-purpose ones, and the output is marked as double-float. Nothing
reports this if every object goes through LTO. For instance, a shared library
built this way links without error, and so does lp64s code built without LTO that
uses it. Without an FPU, the generated code keeps the soft-float calling
convention, but the output is still marked as double-float.

The mismatch only shows up as an error when LTO output is linked
together with relocatable objects built without LTO, which LLD rejects with "cannot
link object files with different ABI".

This patch adds LoongArch to the targets for which clang emits the flag,
so LTO uses the ABI the code was compiled for. It follows the per-target
approach taken for ARM (#217601) and PowerPC (#221669), and leaves the existing 
TODO about emitting the flag for every target with a non-empty ABI name as is.

With the flag present, LTO-linking bitcode built for different LoongArch
ABIs now fails with "linking module flags 'target-abi': IDs have conflicting
values" instead of silently picking a single ABI. A -target-abi given to the LTO
backend that disagrees with the flag is now also an error. Both match the
existing RISC-V behavior.

Assisted-by: Claude Code (Claude Opus 5)

Signed-off-by: Mintsuki <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend:ARM clang:codegen IR generation bugs: mangling, exceptions, etc. clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants