https://github.com/chrisnc updated https://github.com/llvm/llvm-project/pull/217693
>From 772cddbe3c7193d973c158c6d5ae01514d324d66 Mon Sep 17 00:00:00 2001 From: Chris Copeland <[email protected]> Date: Tue, 18 Aug 2026 23:21:58 -0700 Subject: [PATCH] [ARM] Name caller and callee in unsupported hard-float calling convention error message Add a clang test for the diagnostic output covering cases with and without debuginfo. --- clang/test/CodeGen/arm-eabihf-no-fpregs.c | 35 +++++++++++++++++++++++ llvm/lib/Target/ARM/ARMTargetMachine.cpp | 6 ++-- llvm/test/CodeGen/ARM/eabihf-no-fpregs.ll | 6 ++-- 3 files changed, 42 insertions(+), 5 deletions(-) create mode 100644 clang/test/CodeGen/arm-eabihf-no-fpregs.c diff --git a/clang/test/CodeGen/arm-eabihf-no-fpregs.c b/clang/test/CodeGen/arm-eabihf-no-fpregs.c new file mode 100644 index 0000000000000..efe12e2243685 --- /dev/null +++ b/clang/test/CodeGen/arm-eabihf-no-fpregs.c @@ -0,0 +1,35 @@ +// REQUIRES: arm-registered-target +// RUN: not %clang --target=armv7r-none-eabihf -g -c %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=DEBUG +// RUN: not %clang --target=armv7r-none-eabihf -c %s -o /dev/null 2>&1 | FileCheck %s --check-prefix=NODEBUG + +// DEBUG: arm-eabihf-no-fpregs.c:12:1: error: calling convention is hard-float, but floating-point registers are unavailable +// DEBUG-NEXT{LITERAL}: 12 | void hard_fn(void) {} +// DEBUG-NEXT{LITERAL}: | ^ +// NODEBUG: arm-eabihf-no-fpregs.c:12:6: error: calling convention is hard-float, but floating-point registers are unavailable +// NODEBUG-NEXT{LITERAL}: 12 | void hard_fn(void) {} +// NODEBUG-NEXT{LITERAL}: | ^ +__attribute__((target("no-fpregs"))) +void hard_fn(void) {} + +// DEBUG: arm-eabihf-no-fpregs.c:23:3: error: 'soft_to_hard' calls 'hard_callee', which expects a hard-float calling convention, but floating-point registers are unavailable +// DEBUG-NEXT{LITERAL}: 23 | hard_callee(); +// DEBUG-NEXT{LITERAL}: | ^ +// NODEBUG: arm-eabihf-no-fpregs.c:21:6: error: 'soft_to_hard' calls 'hard_callee', which expects a hard-float calling convention, but floating-point registers are unavailable +// NODEBUG-NEXT{LITERAL}: 21 | void soft_to_hard(void) { +// NODEBUG-NEXT{LITERAL}: | ^ +__attribute__((target("no-fpregs"), pcs("aapcs"))) +void soft_to_hard(void) { + extern void hard_callee(void); + hard_callee(); +} + +// DEBUG: arm-eabihf-no-fpregs.c:34:3: error: 'soft_to_indirect' makes an indirect call that expects a hard-float calling convention, but floating-point registers are unavailable +// DEBUG-NEXT{LITERAL}: 34 | p(); +// DEBUG-NEXT{LITERAL}: | ^ +// NODEBUG: arm-eabihf-no-fpregs.c:33:6: error: 'soft_to_indirect' makes an indirect call that expects a hard-float calling convention, but floating-point registers are unavailable +// NODEBUG-NEXT{LITERAL}: 33 | void soft_to_indirect(void (*p)(void)) { +// NODEBUG-NEXT{LITERAL}: | ^ +__attribute__((target("no-fpregs"), pcs("aapcs"))) +void soft_to_indirect(void (*p)(void)) { + p(); +} diff --git a/llvm/lib/Target/ARM/ARMTargetMachine.cpp b/llvm/lib/Target/ARM/ARMTargetMachine.cpp index 4c5eda5705ea4..7405e364e9343 100644 --- a/llvm/lib/Target/ARM/ARMTargetMachine.cpp +++ b/llvm/lib/Target/ARM/ARMTargetMachine.cpp @@ -221,8 +221,10 @@ MachineFunctionInfo *ARMBaseTargetMachine::createMachineFunctionInfo( const Function *Callee = CB->getCalledFunction(); F.getContext().diagnose(DiagnosticInfoUnsupported( F, - (Callee ? Twine("call to '") + Callee->getName() + "'" - : Twine("indirect call")) + + (Callee ? Twine("'") + F.getName() + "' calls '" + + Callee->getName() + "', which" + : Twine("'") + F.getName() + + "' makes an indirect call that") + " expects a hard-float calling convention" + FPRegsUnavailableMsg, CB->getDebugLoc())); diff --git a/llvm/test/CodeGen/ARM/eabihf-no-fpregs.ll b/llvm/test/CodeGen/ARM/eabihf-no-fpregs.ll index cdc70a249c760..777f812cac3d5 100644 --- a/llvm/test/CodeGen/ARM/eabihf-no-fpregs.ll +++ b/llvm/test/CodeGen/ARM/eabihf-no-fpregs.ll @@ -20,15 +20,15 @@ define void @variadic(...) { ret void } -; CHECK: error: {{.*}} in function soft_to_hard {{.*}}: call to 'hard_callee' expects a hard-float calling convention, but floating-point registers are unavailable -; CHECK: error: {{.*}} call to 'hard_callee2' expects a hard-float calling convention, but floating-point registers are unavailable +; CHECK: error: {{.*}} in function soft_to_hard {{.*}}: 'soft_to_hard' calls 'hard_callee', which expects a hard-float calling convention, but floating-point registers are unavailable +; CHECK: error: {{.*}} 'soft_to_hard' calls 'hard_callee2', which expects a hard-float calling convention, but floating-point registers are unavailable define arm_aapcscc void @soft_to_hard() { call arm_aapcs_vfpcc void @hard_callee() call arm_aapcs_vfpcc void @hard_callee2() ret void } -; EABIHF: error: {{.*}} in function soft_to_default_hard {{.*}}: call to 'default_callee' expects a hard-float calling convention, but floating-point registers are unavailable +; EABIHF: error: {{.*}} in function soft_to_default_hard {{.*}}: 'soft_to_default_hard' calls 'default_callee', which expects a hard-float calling convention, but floating-point registers are unavailable define arm_aapcscc void @soft_to_default_hard() { call void @default_callee() ret void _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
