[llvm] [ARM] Emit an error when the hard-float ABI is enabled but can't be used. (PR #111334)
Chris Copeland via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 6 20:46:04 PDT 2024
https://github.com/chrisnc created https://github.com/llvm/llvm-project/pull/111334
Currently, compiling for eabihf with a CPU lacking floating-point
registers will silently use the soft-float ABI instead, even though the
Arm attributes section still has Tag_ABI_VFP_args: VFP registers, which
leads to silent ABI mismatches at link time.
Fixes #110383.
>From eb5ed186be89af9760c8f55616811b05dd9b20ca Mon Sep 17 00:00:00 2001
From: Chris Copeland <chris at chrisnc.net>
Date: Sun, 6 Oct 2024 20:27:48 -0700
Subject: [PATCH] [ARM] Emit an error when the hard-float ABI is enabled but
can't be used.
Currently, compiling for eabihf with a CPU lacking floating-point
registers will silently use the soft-float ABI instead, even though the
Arm attributes section still has Tag_ABI_VFP_args: VFP registers, which
leads to silent ABI mismatches at link time.
Fixes #110383.
---
llvm/lib/Target/ARM/ARMTargetMachine.cpp | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Target/ARM/ARMTargetMachine.cpp b/llvm/lib/Target/ARM/ARMTargetMachine.cpp
index 7553778c574033..82927a7430b5d0 100644
--- a/llvm/lib/Target/ARM/ARMTargetMachine.cpp
+++ b/llvm/lib/Target/ARM/ARMTargetMachine.cpp
@@ -309,11 +309,15 @@ ARMBaseTargetMachine::getSubtargetImpl(const Function &F) const {
// function that reside in TargetOptions.
resetTargetOptions(F);
I = std::make_unique<ARMSubtarget>(TargetTriple, CPU, FS, *this, isLittle,
- F.hasMinSize());
+ F.hasMinSize());
if (!I->isThumb() && !I->hasARMOps())
F.getContext().emitError("Function '" + F.getName() + "' uses ARM "
"instructions, but the target does not support ARM mode execution.");
+
+ if (I->isTargetHardFloat() && !I->hasFPRegs())
+ F.getContext().emitError("The hardfloat ABI is enabled, but the target "
+ "lacks floating-point registers.");
}
return I.get();
More information about the llvm-commits
mailing list