[llvm-branch-commits] [llvm] ARM: Remove subtarget field tracking SjLj (PR #147226)
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sun Jul 6 18:29:20 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-arm
Author: Matt Arsenault (arsenm)
<details>
<summary>Changes</summary>
This is a module level property that needs to be globally
consistent, so it does not belong in the subtarget.
Now that the Triple knows the default exception handling type,
consolidate the interpretation of None as select target default
exception handling in TargetMachine and use that. This enables
moving the configuration of UNWIND_RESUME to RuntimeLibcalls.
---
Full diff: https://github.com/llvm/llvm-project/pull/147226.diff
4 Files Affected:
- (modified) llvm/include/llvm/Target/TargetMachine.h (+9)
- (modified) llvm/lib/Target/ARM/ARMISelLowering.cpp (+4-2)
- (modified) llvm/lib/Target/ARM/ARMSubtarget.cpp (-14)
- (modified) llvm/lib/Target/ARM/ARMSubtarget.h (-5)
``````````diff
diff --git a/llvm/include/llvm/Target/TargetMachine.h b/llvm/include/llvm/Target/TargetMachine.h
index 7a37eb7391b31..bf4e490554723 100644
--- a/llvm/include/llvm/Target/TargetMachine.h
+++ b/llvm/include/llvm/Target/TargetMachine.h
@@ -243,6 +243,15 @@ class LLVM_ABI TargetMachine {
const MCInstrInfo *getMCInstrInfo() const { return MII.get(); }
const MCSubtargetInfo *getMCSubtargetInfo() const { return STI.get(); }
+ /// Return the ExceptionHandling to use, considering TargetOptions and the
+ /// Triple's default.
+ ExceptionHandling getExceptionModel() const {
+ // FIXME: This interface fails to distinguish default from not supported.
+ return Options.ExceptionModel == ExceptionHandling::None
+ ? TargetTriple.getDefaultExceptionHandling()
+ : Options.ExceptionModel;
+ }
+
bool requiresStructuredCFG() const { return RequireStructuredCFG; }
void setRequiresStructuredCFG(bool Value) { RequireStructuredCFG = Value; }
diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp
index 2d73725291d11..6be41a01e0696 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -21959,14 +21959,16 @@ Register ARMTargetLowering::getExceptionPointerRegister(
const Constant *PersonalityFn) const {
// Platforms which do not use SjLj EH may return values in these registers
// via the personality function.
- return Subtarget->useSjLjEH() ? Register() : ARM::R0;
+ ExceptionHandling EM = getTargetMachine().getExceptionModel();
+ return EM == ExceptionHandling::SjLj ? Register() : ARM::R0;
}
Register ARMTargetLowering::getExceptionSelectorRegister(
const Constant *PersonalityFn) const {
// Platforms which do not use SjLj EH may return values in these registers
// via the personality function.
- return Subtarget->useSjLjEH() ? Register() : ARM::R1;
+ ExceptionHandling EM = getTargetMachine().getExceptionModel();
+ return EM == ExceptionHandling::SjLj ? Register() : ARM::R1;
}
void ARMTargetLowering::initializeSplitCSR(MachineBasicBlock *Entry) const {
diff --git a/llvm/lib/Target/ARM/ARMSubtarget.cpp b/llvm/lib/Target/ARM/ARMSubtarget.cpp
index abca4bb947bc4..13185a7d797a3 100644
--- a/llvm/lib/Target/ARM/ARMSubtarget.cpp
+++ b/llvm/lib/Target/ARM/ARMSubtarget.cpp
@@ -72,7 +72,6 @@ ForceFastISel("arm-force-fast-isel",
/// so that we can use initializer lists for subtarget initialization.
ARMSubtarget &ARMSubtarget::initializeSubtargetDependencies(StringRef CPU,
StringRef FS) {
- initializeEnvironment();
initSubtargetFeatures(CPU, FS);
return *this;
}
@@ -137,19 +136,6 @@ bool ARMSubtarget::isXRaySupported() const {
return hasV6Ops() && hasARMOps() && !isTargetWindows();
}
-void ARMSubtarget::initializeEnvironment() {
- // MCAsmInfo isn't always present (e.g. in opt) so we can't initialize this
- // directly from it, but we can try to make sure they're consistent when both
- // available.
- UseSjLjEH = (isTargetDarwin() && !isTargetWatchABI() &&
- Options.ExceptionModel == ExceptionHandling::None) ||
- Options.ExceptionModel == ExceptionHandling::SjLj;
- assert((!TM.getMCAsmInfo() ||
- (TM.getMCAsmInfo()->getExceptionHandlingType() ==
- ExceptionHandling::SjLj) == UseSjLjEH) &&
- "inconsistent sjlj choice between CodeGen and MC");
-}
-
void ARMSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
if (CPUString.empty()) {
CPUString = "generic";
diff --git a/llvm/lib/Target/ARM/ARMSubtarget.h b/llvm/lib/Target/ARM/ARMSubtarget.h
index 3e1314349564c..beb1ff6447148 100644
--- a/llvm/lib/Target/ARM/ARMSubtarget.h
+++ b/llvm/lib/Target/ARM/ARMSubtarget.h
@@ -151,9 +151,6 @@ class ARMSubtarget : public ARMGenSubtargetInfo {
/// blocks.
bool RestrictIT = false;
- /// UseSjLjEH - If true, the target uses SjLj exception handling (e.g. iOS).
- bool UseSjLjEH = false;
-
/// stackAlignment - The minimum alignment known to hold of the stack frame on
/// entry to the function and which must be maintained by every function.
Align stackAlignment = Align(4);
@@ -270,7 +267,6 @@ class ARMSubtarget : public ARMGenSubtargetInfo {
std::unique_ptr<LegalizerInfo> Legalizer;
std::unique_ptr<RegisterBankInfo> RegBankInfo;
- void initializeEnvironment();
void initSubtargetFeatures(StringRef CPU, StringRef FS);
ARMFrameLowering *initializeFrameLowering(StringRef CPU, StringRef FS);
@@ -321,7 +317,6 @@ class ARMSubtarget : public ARMGenSubtargetInfo {
}
bool useFPVFMx16() const { return useFPVFMx() && hasFullFP16(); }
bool useFPVFMx64() const { return useFPVFMx() && hasFP64(); }
- bool useSjLjEH() const { return UseSjLjEH; }
bool hasBaseDSP() const {
if (isThumb())
return hasThumb2() && hasDSP();
``````````
</details>
https://github.com/llvm/llvm-project/pull/147226
More information about the llvm-branch-commits
mailing list