diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.h b/llvm/include/llvm/IR/RuntimeLibcalls.h index 3e1531ebfd9d6..a6a180f5ed8db 100644 --- a/llvm/include/llvm/IR/RuntimeLibcalls.h +++ b/llvm/include/llvm/IR/RuntimeLibcalls.h @@ -19,6 +19,7 @@ #include "llvm/IR/CallingConv.h" #include "llvm/IR/InstrTypes.h" #include "llvm/Support/AtomicOrdering.h" +#include "llvm/Support/CodeGen.h" #include "llvm/Support/Compiler.h" #include "llvm/TargetParser/Triple.h" @@ -53,8 +54,10 @@ static inline auto libcalls() { /// A simple container for information about the supported runtime calls. struct RuntimeLibcallsInfo { - explicit RuntimeLibcallsInfo(const Triple &TT) { - initLibcalls(TT); + explicit RuntimeLibcallsInfo(const Triple &TT, + FloatABI::ABIType FloatABI = FloatABI::Default, + EABI EABIVersion = EABI::Default) { + initLibcalls(TT, FloatABI, EABIVersion); } /// Rename the default libcall routine name for the specified libcall. @@ -144,7 +147,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); + LLVM_ABI void initLibcalls(const Triple &TT, FloatABI::ABIType FloatABI, + EABI ABIType); }; } // namespace RTLIB diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp index b1afdc2a3ac39..2b5087cd38f55 100644 --- a/llvm/lib/CodeGen/TargetLoweringBase.cpp +++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp @@ -632,7 +632,8 @@ void RTLIB::initCmpLibcallCCs(ISD::CondCode *CmpLibcallCCs) { /// NOTE: The TargetMachine owns TLOF. TargetLoweringBase::TargetLoweringBase(const TargetMachine &tm) - : TM(tm), Libcalls(TM.getTargetTriple()) { + : TM(tm), Libcalls(TM.getTargetTriple(), 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 a57b089193462..74dccdf172d45 100644 --- a/llvm/lib/IR/RuntimeLibcalls.cpp +++ b/llvm/lib/IR/RuntimeLibcalls.cpp @@ -65,7 +65,17 @@ static void setAArch64LibcallNames(RuntimeLibcallsInfo &Info, #undef LCALLNAME5 } -static void setARMLibcallNames(RuntimeLibcallsInfo &Info, const Triple &TT) { +static void setARMLibcallNames(RuntimeLibcallsInfo &Info, const Triple &TT, + FloatABI::ABIType FloatABIType, + EABI EABIVersion) { + if (!TT.isOSDarwin() && !TT.isiOS() && !TT.isWatchOS() && !TT.isDriverKit()) { + CallingConv::ID DefaultCC = FloatABIType == FloatABI::Hard + ? CallingConv::ARM_AAPCS_VFP + : CallingConv::ARM_AAPCS; + for (RTLIB::Libcall LC : RTLIB::libcalls()) + Info.setLibcallCallingConv(LC, DefaultCC); + } + // Register based DivRem for AEABI (RTABI 4.2) if (TT.isTargetAEABI() || TT.isAndroid() || TT.isTargetGNUAEABI() || TT.isTargetMuslAEABI() || TT.isOSWindows()) { @@ -346,7 +356,9 @@ 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) { +void RuntimeLibcallsInfo::initLibcalls(const Triple &TT, + FloatABI::ABIType FloatABI, + EABI EABIVersion) { initSoftFloatCmpLibcallPredicates(); initSoftFloatCmpLibcallPredicates(); @@ -539,7 +551,7 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT) { if (TT.isAArch64()) setAArch64LibcallNames(*this, TT); else if (TT.isARM() || TT.isThumb()) - setARMLibcallNames(*this, TT); + setARMLibcallNames(*this, TT, FloatABI, EABIVersion); else if (TT.getArch() == Triple::ArchType::avr) { // Division rtlib functions (not supported), use divmod functions instead setLibcallName(RTLIB::SDIV_I8, nullptr); diff --git a/llvm/lib/Object/IRSymtab.cpp b/llvm/lib/Object/IRSymtab.cpp index 806477ae3de01..494ec089d7bd1 100644 --- a/llvm/lib/Object/IRSymtab.cpp +++ b/llvm/lib/Object/IRSymtab.cpp @@ -216,7 +216,7 @@ Expected Builder::getComdatIndex(const Comdat *C, const Module *M) { static DenseSet buildPreservedSymbolsSet(const Triple &TT) { DenseSet PreservedSymbolSet(std::begin(PreservedSymbols), std::end(PreservedSymbols)); - + // FIXME: Do we need to pass in ABI fields from TargetOptions? RTLIB::RuntimeLibcallsInfo Libcalls(TT); for (const char *Name : Libcalls.getLibcallNames()) { if (Name) diff --git a/llvm/lib/Target/ARM/ARMISelLowering.cpp b/llvm/lib/Target/ARM/ARMISelLowering.cpp index 6e653687dbcb3..91fb7bc4578b3 100644 --- a/llvm/lib/Target/ARM/ARMISelLowering.cpp +++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp @@ -515,16 +515,6 @@ ARMTargetLowering::ARMTargetLowering(const TargetMachine &TM_, setBooleanContents(ZeroOrOneBooleanContent); setBooleanVectorContents(ZeroOrNegativeOneBooleanContent); - if (!Subtarget->isTargetDarwin() && !Subtarget->isTargetIOS() && - !Subtarget->isTargetWatchOS() && !Subtarget->isTargetDriverKit()) { - bool IsHFTarget = TM.Options.FloatABIType == FloatABI::Hard; - - for (RTLIB::Libcall LC : RTLIB::libcalls()) { - setLibcallCallingConv(LC, IsHFTarget ? CallingConv::ARM_AAPCS_VFP - : CallingConv::ARM_AAPCS); - } - } - if (Subtarget->isTargetMachO()) { // Uses VFP for Thumb libfuncs if available. if (Subtarget->isThumb() && Subtarget->hasVFP2Base() &&