https://github.com/arsenm updated https://github.com/llvm/llvm-project/pull/144696
>From 98101238be482a61591ec9e72376f2a7a75f19f3 Mon Sep 17 00:00:00 2001 From: Matt Arsenault <matthew.arsena...@amd.com> Date: Wed, 18 Jun 2025 22:01:46 +0900 Subject: [PATCH] RuntimeLibcalls: Pass in exception handling type All of the ABI options that influence libcall decisions need to be passed in. --- llvm/include/llvm/IR/RuntimeLibcalls.h | 14 ++++++++------ llvm/lib/CodeGen/TargetLoweringBase.cpp | 4 ++-- llvm/lib/IR/RuntimeLibcalls.cpp | 6 ++++++ llvm/lib/Target/VE/VEISelLowering.cpp | 2 -- llvm/lib/Target/X86/X86ISelLowering.cpp | 4 ---- 5 files changed, 16 insertions(+), 14 deletions(-) diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.h b/llvm/include/llvm/IR/RuntimeLibcalls.h index a6a180f5ed8db..71f38bedf17e0 100644 --- a/llvm/include/llvm/IR/RuntimeLibcalls.h +++ b/llvm/include/llvm/IR/RuntimeLibcalls.h @@ -54,10 +54,12 @@ static inline auto libcalls() { /// A simple container for information about the supported runtime calls. struct RuntimeLibcallsInfo { - explicit RuntimeLibcallsInfo(const Triple &TT, - FloatABI::ABIType FloatABI = FloatABI::Default, - EABI EABIVersion = EABI::Default) { - initLibcalls(TT, FloatABI, EABIVersion); + explicit RuntimeLibcallsInfo( + const Triple &TT, + ExceptionHandling ExceptionModel = ExceptionHandling::None, + FloatABI::ABIType FloatABI = FloatABI::Default, + EABI EABIVersion = EABI::Default) { + initLibcalls(TT, ExceptionModel, FloatABI, EABIVersion); } /// Rename the default libcall routine name for the specified libcall. @@ -147,8 +149,8 @@ struct RuntimeLibcallsInfo { /// Set default libcall names. If a target wants to opt-out of a libcall it /// should be placed here. - LLVM_ABI void initLibcalls(const Triple &TT, FloatABI::ABIType FloatABI, - EABI ABIType); + LLVM_ABI void initLibcalls(const Triple &TT, ExceptionHandling ExceptionModel, + FloatABI::ABIType FloatABI, EABI ABIType); }; } // namespace RTLIB diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp index 2b5087cd38f55..41e73b8530937 100644 --- a/llvm/lib/CodeGen/TargetLoweringBase.cpp +++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp @@ -632,8 +632,8 @@ void RTLIB::initCmpLibcallCCs(ISD::CondCode *CmpLibcallCCs) { /// NOTE: The TargetMachine owns TLOF. TargetLoweringBase::TargetLoweringBase(const TargetMachine &tm) - : TM(tm), Libcalls(TM.getTargetTriple(), TM.Options.FloatABIType, - TM.Options.EABIVersion) { + : TM(tm), Libcalls(TM.getTargetTriple(), TM.Options.ExceptionModel, + TM.Options.FloatABIType, TM.Options.EABIVersion) { initActions(); // Perform these initializations only once. diff --git a/llvm/lib/IR/RuntimeLibcalls.cpp b/llvm/lib/IR/RuntimeLibcalls.cpp index 74dccdf172d45..ad2904d6d2ea6 100644 --- a/llvm/lib/IR/RuntimeLibcalls.cpp +++ b/llvm/lib/IR/RuntimeLibcalls.cpp @@ -357,6 +357,7 @@ static void setLongDoubleIsF128Libm(RuntimeLibcallsInfo &Info, /// Set default libcall names. If a target wants to opt-out of a libcall it /// should be placed here. void RuntimeLibcallsInfo::initLibcalls(const Triple &TT, + ExceptionHandling ExceptionModel, FloatABI::ABIType FloatABI, EABI EABIVersion) { initSoftFloatCmpLibcallPredicates(); @@ -373,6 +374,11 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT, if (TT.isX86() && TT.isGNUEnvironment()) setLongDoubleIsF128Libm(*this, /*FiniteOnlyFuncs=*/true); + if (TT.isX86() || TT.isVE()) { + if (ExceptionModel == ExceptionHandling::SjLj) + setLibcallName(RTLIB::UNWIND_RESUME, "_Unwind_SjLj_Resume"); + } + // For IEEE quad-precision libcall names, PPC uses "kf" instead of "tf". if (TT.isPPC()) { setLibcallName(RTLIB::ADD_F128, "__addkf3"); diff --git a/llvm/lib/Target/VE/VEISelLowering.cpp b/llvm/lib/Target/VE/VEISelLowering.cpp index b5a0d26abbf8e..98c5fdd138986 100644 --- a/llvm/lib/Target/VE/VEISelLowering.cpp +++ b/llvm/lib/Target/VE/VEISelLowering.cpp @@ -298,8 +298,6 @@ void VETargetLowering::initSPUActions() { setOperationAction(ISD::EH_SJLJ_LONGJMP, MVT::Other, Custom); setOperationAction(ISD::EH_SJLJ_SETJMP, MVT::i32, Custom); setOperationAction(ISD::EH_SJLJ_SETUP_DISPATCH, MVT::Other, Custom); - if (TM.Options.ExceptionModel == ExceptionHandling::SjLj) - setLibcallName(RTLIB::UNWIND_RESUME, "_Unwind_SjLj_Resume"); /// } SJLJ instructions // Intrinsic instructions diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp index 4751361c71f2c..defb7730b4c7d 100644 --- a/llvm/lib/Target/X86/X86ISelLowering.cpp +++ b/llvm/lib/Target/X86/X86ISelLowering.cpp @@ -513,10 +513,6 @@ X86TargetLowering::X86TargetLowering(const X86TargetMachine &TM, setOperationAction(ISD::EH_SJLJ_LONGJMP, MVT::Other, Custom); setOperationAction(ISD::EH_SJLJ_SETUP_DISPATCH, MVT::Other, Custom); - // FIXME: This should be set in RuntimeLibcallsInfo - if (TM.Options.ExceptionModel == ExceptionHandling::SjLj) - setLibcallName(RTLIB::UNWIND_RESUME, "_Unwind_SjLj_Resume"); - // Darwin ABI issue. for (auto VT : { MVT::i32, MVT::i64 }) { if (VT == MVT::i64 && !Subtarget.is64Bit()) _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits