[llvm] [ARM] Emit an error when the hard-float ABI is enabled but can't be used (PR #111334)

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 31 05:42:53 PDT 2026


================
@@ -1,4 +1,4 @@
-; RUN: llc -mtriple=arm-linux-gnueabihf -filetype=obj <%s | llvm-objdump --triple=armv7 --no-show-raw-insn -d - | FileCheck %s
+; RUN: llc -mtriple=arm-linux-gnueabi -filetype=obj <%s | llvm-objdump --triple=armv7 --no-show-raw-insn -d - | FileCheck %s
----------------
smithp35 wrote:

This case makes me nervous. 

I was able to reproduce the failure with the following C code:
```
float f(float x, float y) {
  return x/y;
}

__attribute__((pcs("aapcs"))) __attribute__((target("arch=arm7tdmi,no-fpregs"))) float g(float x, float y) {
  return x*y;
}
```
With this patch applied:
```
clang --target=arm-linux-gnueabihf float.c -c -O2
error: Function 'g' uses the hard-float ABI, but the target lacks floating-point registers.
1 error generated.
```
With clang-22 -S output
```
f:                                      @ @f
        .fnstart
@ %bb.0:                                @ %entry
        vdiv.f32        s0, s0, s1
        bx      lr
.Lfunc_end0:
        .size   f, .Lfunc_end0-f
        .cantunwind
        .fnend
                                        @ -- End function
        .globl  g                               @ -- Begin function g
        .p2align        2
        .type   g,%function
        .code   32
g:                                      @ @g
        .fnstart
@ %bb.0:                                @ %entry
        .save   {r11, lr}
        push    {r11, lr}
        bl      __aeabi_fmul
        pop     {r11, lr}
        bx      lr
.Lfunc_end1:
```

Which looks correct to me. I think this may be that the `arm_aapcscc` is not handled by the triple in the Subtarget so it isn't accounted for in the check. 

https://github.com/llvm/llvm-project/pull/111334


More information about the llvm-commits mailing list