ARM: Remove subtarget field tracking SjLj
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.
diff --git a/llvm/include/llvm/Target/TargetMachine.h b/llvm/include/llvm/Target/TargetMachine.h
index 7a37eb7..bf4e490 100644
--- a/llvm/include/llvm/Target/TargetMachine.h
+++ b/llvm/include/llvm/Target/TargetMachine.h
@@ -243,6 +243,15 @@
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 2d73725..6be41a0 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -21959,14 +21959,16 @@
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 abca4bb..13185a7 100644
--- a/llvm/lib/Target/ARM/ARMSubtarget.cpp
+++ b/llvm/lib/Target/ARM/ARMSubtarget.cpp
@@ -72,7 +72,6 @@
/// 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 @@
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 3e13143..beb1ff6 100644
--- a/llvm/lib/Target/ARM/ARMSubtarget.h
+++ b/llvm/lib/Target/ARM/ARMSubtarget.h
@@ -151,9 +151,6 @@
/// 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 @@
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 @@
}
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();