Skip to content

Commit 1c35fe4

Browse files
authored
RuntimeLibcalls: Pass in exception handling type (#144696)
All of the ABI options that influence libcall decisions need to be passed in.
1 parent 305953a commit 1c35fe4

File tree

5 files changed

+16
-14
lines changed

5 files changed

+16
-14
lines changed

llvm/include/llvm/IR/RuntimeLibcalls.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,12 @@ static inline auto libcalls() {
5454

5555
/// A simple container for information about the supported runtime calls.
5656
struct RuntimeLibcallsInfo {
57-
explicit RuntimeLibcallsInfo(const Triple &TT,
58-
FloatABI::ABIType FloatABI = FloatABI::Default,
59-
EABI EABIVersion = EABI::Default) {
60-
initLibcalls(TT, FloatABI, EABIVersion);
57+
explicit RuntimeLibcallsInfo(
58+
const Triple &TT,
59+
ExceptionHandling ExceptionModel = ExceptionHandling::None,
60+
FloatABI::ABIType FloatABI = FloatABI::Default,
61+
EABI EABIVersion = EABI::Default) {
62+
initLibcalls(TT, ExceptionModel, FloatABI, EABIVersion);
6163
}
6264

6365
/// Rename the default libcall routine name for the specified libcall.
@@ -147,8 +149,8 @@ struct RuntimeLibcallsInfo {
147149

148150
/// Set default libcall names. If a target wants to opt-out of a libcall it
149151
/// should be placed here.
150-
LLVM_ABI void initLibcalls(const Triple &TT, FloatABI::ABIType FloatABI,
151-
EABI ABIType);
152+
LLVM_ABI void initLibcalls(const Triple &TT, ExceptionHandling ExceptionModel,
153+
FloatABI::ABIType FloatABI, EABI ABIType);
152154
};
153155

154156
} // namespace RTLIB

llvm/lib/CodeGen/TargetLoweringBase.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -632,8 +632,8 @@ void RTLIB::initCmpLibcallCCs(ISD::CondCode *CmpLibcallCCs) {
632632

633633
/// NOTE: The TargetMachine owns TLOF.
634634
TargetLoweringBase::TargetLoweringBase(const TargetMachine &tm)
635-
: TM(tm), Libcalls(TM.getTargetTriple(), TM.Options.FloatABIType,
636-
TM.Options.EABIVersion) {
635+
: TM(tm), Libcalls(TM.getTargetTriple(), TM.Options.ExceptionModel,
636+
TM.Options.FloatABIType, TM.Options.EABIVersion) {
637637
initActions();
638638

639639
// Perform these initializations only once.

llvm/lib/IR/RuntimeLibcalls.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ static void setLongDoubleIsF128Libm(RuntimeLibcallsInfo &Info,
357357
/// Set default libcall names. If a target wants to opt-out of a libcall it
358358
/// should be placed here.
359359
void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
360+
ExceptionHandling ExceptionModel,
360361
FloatABI::ABIType FloatABI,
361362
EABI EABIVersion) {
362363
initSoftFloatCmpLibcallPredicates();
@@ -373,6 +374,11 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT,
373374
if (TT.isX86() && TT.isGNUEnvironment())
374375
setLongDoubleIsF128Libm(*this, /*FiniteOnlyFuncs=*/true);
375376

377+
if (TT.isX86() || TT.isVE()) {
378+
if (ExceptionModel == ExceptionHandling::SjLj)
379+
setLibcallName(RTLIB::UNWIND_RESUME, "_Unwind_SjLj_Resume");
380+
}
381+
376382
// For IEEE quad-precision libcall names, PPC uses "kf" instead of "tf".
377383
if (TT.isPPC()) {
378384
setLibcallName(RTLIB::ADD_F128, "__addkf3");

llvm/lib/Target/VE/VEISelLowering.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,6 @@ void VETargetLowering::initSPUActions() {
298298
setOperationAction(ISD::EH_SJLJ_LONGJMP, MVT::Other, Custom);
299299
setOperationAction(ISD::EH_SJLJ_SETJMP, MVT::i32, Custom);
300300
setOperationAction(ISD::EH_SJLJ_SETUP_DISPATCH, MVT::Other, Custom);
301-
if (TM.Options.ExceptionModel == ExceptionHandling::SjLj)
302-
setLibcallName(RTLIB::UNWIND_RESUME, "_Unwind_SjLj_Resume");
303301
/// } SJLJ instructions
304302

305303
// Intrinsic instructions

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -513,10 +513,6 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM,
513513
setOperationAction(ISD::EH_SJLJ_LONGJMP, MVT::Other, Custom);
514514
setOperationAction(ISD::EH_SJLJ_SETUP_DISPATCH, MVT::Other, Custom);
515515

516-
// FIXME: This should be set in RuntimeLibcallsInfo
517-
if (TM.Options.ExceptionModel == ExceptionHandling::SjLj)
518-
setLibcallName(RTLIB::UNWIND_RESUME, "_Unwind_SjLj_Resume");
519-
520516
// Darwin ABI issue.
521517
for (auto VT : { MVT::i32, MVT::i64 }) {
522518
if (VT == MVT::i64 && !Subtarget.is64Bit())

0 commit comments

Comments
 (0)