-
Notifications
You must be signed in to change notification settings - Fork 14.3k
RuntimeLibcalls: Pass in FloatABI and EABI type #144691
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RuntimeLibcalls: Pass in FloatABI and EABI type #144691
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
@llvm/pr-subscribers-llvm-binary-utilities @llvm/pr-subscribers-llvm-ir Author: Matt Arsenault (arsenm) ChangesWe need the full set of ABI options to accurately compute Full diff: https://github.com/llvm/llvm-project/pull/144691.diff 5 Files Affected:
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<int> Builder::getComdatIndex(const Comdat *C, const Module *M) {
static DenseSet<StringRef> buildPreservedSymbolsSet(const Triple &TT) {
DenseSet<StringRef> 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 05d8a1190ada8..500ce9dc364ee 100644
--- a/llvm/lib/Target/ARM/ARMISelLowering.cpp
+++ b/llvm/lib/Target/ARM/ARMISelLowering.cpp
@@ -508,16 +508,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() &&
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks reasonable to me. I've added the Arm maintainers just in case they've got anything to add.
static void setARMLibcallNames(RuntimeLibcallsInfo &Info, const Triple &TT) { | ||
static void setARMLibcallNames(RuntimeLibcallsInfo &Info, const Triple &TT, | ||
FloatABI::ABIType FloatABIType, | ||
EABI EABIVersion) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The EABIVersion doesn't seem to be used by this function, or at least not yet.
Looks like it is only used in https://github.com/llvm/llvm-project/blob/main/llvm/lib/Target/ARM/ARMISelLowering.cpp#L693
Is the intention to move that part of the code to here at some point?
My apologies if I've missed some context, just seeing these reviews for the first time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, eventually the full list of possible libcalls should be recorded here. Later there will also need to be a separate mechanism for making context dependent lowering selections from the full set
3bf268a
to
1011a26
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Strictly speaking I don't think we actually need the CC information at the IR level, but I also don't think that actually separating it makes sense.
You do if you want to emit a call from the IR. Some uses assume the calling convention and emit the call by name directly (e.g. asan) and I want to fix those eventually |
We need the full set of ABI options to accurately compute the full set of libcalls. This partially resolves missing information required to compute the set of ARM calls.
1011a26
to
4b38ca2
Compare
We need the full set of ABI options to accurately compute
the full set of libcalls. This partially resolves missing
information required to compute the set of ARM calls.