Skip to content

Commit 8629db3

Browse files
committed
AArch64: Move outline atomic libcalls configuration
This de-conditionalizes the setting of the libcall names on outlineAtomics() && !hasLSE(). The existence of the libcall is a module level property, which cannot depend on the subtarget so this is fine. It's better if the initial list of calls has more entries than will be used than to have missing ones. There aren't any alternative names set, so this is also fine. Currently RuntimeLibcallsInfo conflates the existence of the calls with the lowering usage decision, so this suboptimally will report the libcall name on subtargets that should not use the calls. This doesn't matter in this case though, as the atomic lowering actions are already separately controlled and aren't based on decisions on libcall availability. We could be paranoid and clear the names in TargetLowering. Also fixes not catching all aarch64 triples in the RuntimeLibcallsInfo construction; the previous check missed aarch64_be.
1 parent 1ffd9f5 commit 8629db3

File tree

2 files changed

+23
-22
lines changed

2 files changed

+23
-22
lines changed

llvm/lib/IR/RuntimeLibcalls.cpp

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,28 @@ static cl::opt<bool>
1818

1919
static void setAArch64LibcallNames(RuntimeLibcallsInfo &Info,
2020
const Triple &TT) {
21+
#define LCALLNAMES(A, B, N) \
22+
Info.setLibcallName(A##N##_RELAX, #B #N "_relax"); \
23+
Info.setLibcallName(A##N##_ACQ, #B #N "_acq"); \
24+
Info.setLibcallName(A##N##_REL, #B #N "_rel"); \
25+
Info.setLibcallName(A##N##_ACQ_REL, #B #N "_acq_rel");
26+
#define LCALLNAME4(A, B) \
27+
LCALLNAMES(A, B, 1) \
28+
LCALLNAMES(A, B, 2) LCALLNAMES(A, B, 4) LCALLNAMES(A, B, 8)
29+
#define LCALLNAME5(A, B) \
30+
LCALLNAMES(A, B, 1) \
31+
LCALLNAMES(A, B, 2) \
32+
LCALLNAMES(A, B, 4) LCALLNAMES(A, B, 8) LCALLNAMES(A, B, 16)
33+
LCALLNAME5(RTLIB::OUTLINE_ATOMIC_CAS, __aarch64_cas)
34+
LCALLNAME4(RTLIB::OUTLINE_ATOMIC_SWP, __aarch64_swp)
35+
LCALLNAME4(RTLIB::OUTLINE_ATOMIC_LDADD, __aarch64_ldadd)
36+
LCALLNAME4(RTLIB::OUTLINE_ATOMIC_LDSET, __aarch64_ldset)
37+
LCALLNAME4(RTLIB::OUTLINE_ATOMIC_LDCLR, __aarch64_ldclr)
38+
LCALLNAME4(RTLIB::OUTLINE_ATOMIC_LDEOR, __aarch64_ldeor)
39+
#undef LCALLNAMES
40+
#undef LCALLNAME4
41+
#undef LCALLNAME5
42+
2143
if (TT.isWindowsArm64EC()) {
2244
// FIXME: are there calls we need to exclude from this?
2345
#define HANDLE_LIBCALL(code, name) \
@@ -520,7 +542,7 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT) {
520542
}
521543
}
522544

523-
if (TT.getArch() == Triple::ArchType::aarch64)
545+
if (TT.isAArch64())
524546
setAArch64LibcallNames(*this, TT);
525547
else if (TT.isARM() || TT.isThumb())
526548
setARMLibcallNames(*this, TT);

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -959,27 +959,6 @@ AArch64TargetLowering::AArch64TargetLowering(const TargetMachine &TM,
959959
setOperationAction(ISD::ATOMIC_LOAD_XOR, MVT::i16, LibCall);
960960
setOperationAction(ISD::ATOMIC_LOAD_XOR, MVT::i32, LibCall);
961961
setOperationAction(ISD::ATOMIC_LOAD_XOR, MVT::i64, LibCall);
962-
#define LCALLNAMES(A, B, N) \
963-
setLibcallName(A##N##_RELAX, #B #N "_relax"); \
964-
setLibcallName(A##N##_ACQ, #B #N "_acq"); \
965-
setLibcallName(A##N##_REL, #B #N "_rel"); \
966-
setLibcallName(A##N##_ACQ_REL, #B #N "_acq_rel");
967-
#define LCALLNAME4(A, B) \
968-
LCALLNAMES(A, B, 1) \
969-
LCALLNAMES(A, B, 2) LCALLNAMES(A, B, 4) LCALLNAMES(A, B, 8)
970-
#define LCALLNAME5(A, B) \
971-
LCALLNAMES(A, B, 1) \
972-
LCALLNAMES(A, B, 2) \
973-
LCALLNAMES(A, B, 4) LCALLNAMES(A, B, 8) LCALLNAMES(A, B, 16)
974-
LCALLNAME5(RTLIB::OUTLINE_ATOMIC_CAS, __aarch64_cas)
975-
LCALLNAME4(RTLIB::OUTLINE_ATOMIC_SWP, __aarch64_swp)
976-
LCALLNAME4(RTLIB::OUTLINE_ATOMIC_LDADD, __aarch64_ldadd)
977-
LCALLNAME4(RTLIB::OUTLINE_ATOMIC_LDSET, __aarch64_ldset)
978-
LCALLNAME4(RTLIB::OUTLINE_ATOMIC_LDCLR, __aarch64_ldclr)
979-
LCALLNAME4(RTLIB::OUTLINE_ATOMIC_LDEOR, __aarch64_ldeor)
980-
#undef LCALLNAMES
981-
#undef LCALLNAME4
982-
#undef LCALLNAME5
983962
}
984963

985964
if (Subtarget->outlineAtomics() && !Subtarget->hasLSFE()) {

0 commit comments

Comments
 (0)