Skip to content

Commit 2bd31ed

Browse files
committed
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. Manually submitting, closes #147226
1 parent 6efa366 commit 2bd31ed

File tree

4 files changed

+14
-22
lines changed

4 files changed

+14
-22
lines changed

llvm/include/llvm/Target/TargetMachine.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,15 @@ class LLVM_ABI TargetMachine {
243243
const MCInstrInfo *getMCInstrInfo() const { return MII.get(); }
244244
const MCSubtargetInfo *getMCSubtargetInfo() const { return STI.get(); }
245245

246+
/// Return the ExceptionHandling to use, considering TargetOptions and the
247+
/// Triple's default.
248+
ExceptionHandling getExceptionModel() const {
249+
// FIXME: This interface fails to distinguish default from not supported.
250+
return Options.ExceptionModel == ExceptionHandling::None
251+
? TargetTriple.getDefaultExceptionHandling()
252+
: Options.ExceptionModel;
253+
}
254+
246255
bool requiresStructuredCFG() const { return RequireStructuredCFG; }
247256
void setRequiresStructuredCFG(bool Value) { RequireStructuredCFG = Value; }
248257

llvm/lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1400,7 +1400,7 @@ ARMTargetLowering::ARMTargetLowering(const TargetMachine &TM_,
14001400
setOperationAction(ISD::EH_SJLJ_SETJMP, MVT::i32, Custom);
14011401
setOperationAction(ISD::EH_SJLJ_LONGJMP, MVT::Other, Custom);
14021402
setOperationAction(ISD::EH_SJLJ_SETUP_DISPATCH, MVT::Other, Custom);
1403-
if (Subtarget->useSjLjEH())
1403+
if (getTargetMachine().getExceptionModel() == ExceptionHandling::SjLj)
14041404
setLibcallImpl(RTLIB::UNWIND_RESUME, RTLIB::_Unwind_SjLj_Resume);
14051405

14061406
setOperationAction(ISD::SETCC, MVT::i32, Expand);
@@ -21961,14 +21961,16 @@ Register ARMTargetLowering::getExceptionPointerRegister(
2196121961
const Constant *PersonalityFn) const {
2196221962
// Platforms which do not use SjLj EH may return values in these registers
2196321963
// via the personality function.
21964-
return Subtarget->useSjLjEH() ? Register() : ARM::R0;
21964+
ExceptionHandling EM = getTargetMachine().getExceptionModel();
21965+
return EM == ExceptionHandling::SjLj ? Register() : ARM::R0;
2196521966
}
2196621967

2196721968
Register ARMTargetLowering::getExceptionSelectorRegister(
2196821969
const Constant *PersonalityFn) const {
2196921970
// Platforms which do not use SjLj EH may return values in these registers
2197021971
// via the personality function.
21971-
return Subtarget->useSjLjEH() ? Register() : ARM::R1;
21972+
ExceptionHandling EM = getTargetMachine().getExceptionModel();
21973+
return EM == ExceptionHandling::SjLj ? Register() : ARM::R1;
2197221974
}
2197321975

2197421976
void ARMTargetLowering::initializeSplitCSR(MachineBasicBlock *Entry) const {

llvm/lib/Target/ARM/ARMSubtarget.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ ForceFastISel("arm-force-fast-isel",
7272
/// so that we can use initializer lists for subtarget initialization.
7373
ARMSubtarget &ARMSubtarget::initializeSubtargetDependencies(StringRef CPU,
7474
StringRef FS) {
75-
initializeEnvironment();
7675
initSubtargetFeatures(CPU, FS);
7776
return *this;
7877
}
@@ -137,19 +136,6 @@ bool ARMSubtarget::isXRaySupported() const {
137136
return hasV6Ops() && hasARMOps() && !isTargetWindows();
138137
}
139138

140-
void ARMSubtarget::initializeEnvironment() {
141-
// MCAsmInfo isn't always present (e.g. in opt) so we can't initialize this
142-
// directly from it, but we can try to make sure they're consistent when both
143-
// available.
144-
UseSjLjEH = (isTargetDarwin() && !isTargetWatchABI() &&
145-
Options.ExceptionModel == ExceptionHandling::None) ||
146-
Options.ExceptionModel == ExceptionHandling::SjLj;
147-
assert((!TM.getMCAsmInfo() ||
148-
(TM.getMCAsmInfo()->getExceptionHandlingType() ==
149-
ExceptionHandling::SjLj) == UseSjLjEH) &&
150-
"inconsistent sjlj choice between CodeGen and MC");
151-
}
152-
153139
void ARMSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
154140
if (CPUString.empty()) {
155141
CPUString = "generic";

llvm/lib/Target/ARM/ARMSubtarget.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,6 @@ class ARMSubtarget : public ARMGenSubtargetInfo {
151151
/// blocks.
152152
bool RestrictIT = false;
153153

154-
/// UseSjLjEH - If true, the target uses SjLj exception handling (e.g. iOS).
155-
bool UseSjLjEH = false;
156-
157154
/// stackAlignment - The minimum alignment known to hold of the stack frame on
158155
/// entry to the function and which must be maintained by every function.
159156
Align stackAlignment = Align(4);
@@ -270,7 +267,6 @@ class ARMSubtarget : public ARMGenSubtargetInfo {
270267
std::unique_ptr<LegalizerInfo> Legalizer;
271268
std::unique_ptr<RegisterBankInfo> RegBankInfo;
272269

273-
void initializeEnvironment();
274270
void initSubtargetFeatures(StringRef CPU, StringRef FS);
275271
ARMFrameLowering *initializeFrameLowering(StringRef CPU, StringRef FS);
276272

@@ -321,7 +317,6 @@ class ARMSubtarget : public ARMGenSubtargetInfo {
321317
}
322318
bool useFPVFMx16() const { return useFPVFMx() && hasFullFP16(); }
323319
bool useFPVFMx64() const { return useFPVFMx() && hasFP64(); }
324-
bool useSjLjEH() const { return UseSjLjEH; }
325320
bool hasBaseDSP() const {
326321
if (isThumb())
327322
return hasThumb2() && hasDSP();

0 commit comments

Comments
 (0)