Skip to content

Commit 6f7d763

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 c7d8581 commit 6f7d763

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) \
@@ -488,7 +510,7 @@ void RuntimeLibcallsInfo::initLibcalls(const Triple &TT) {
488510
}
489511
}
490512

491-
if (TT.getArch() == Triple::ArchType::aarch64)
513+
if (TT.isAArch64())
492514
setAArch64LibcallNames(*this, TT);
493515
else if (TT.isARM() || TT.isThumb())
494516
setARMLibcallNames(*this, TT);

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -966,27 +966,6 @@ AArch64TargetLowering::AArch64TargetLowering(const TargetMachine &TM,
966966
setOperationAction(ISD::ATOMIC_LOAD_XOR, MVT::i16, LibCall);
967967
setOperationAction(ISD::ATOMIC_LOAD_XOR, MVT::i32, LibCall);
968968
setOperationAction(ISD::ATOMIC_LOAD_XOR, MVT::i64, LibCall);
969-
#define LCALLNAMES(A, B, N) \
970-
setLibcallName(A##N##_RELAX, #B #N "_relax"); \
971-
setLibcallName(A##N##_ACQ, #B #N "_acq"); \
972-
setLibcallName(A##N##_REL, #B #N "_rel"); \
973-
setLibcallName(A##N##_ACQ_REL, #B #N "_acq_rel");
974-
#define LCALLNAME4(A, B) \
975-
LCALLNAMES(A, B, 1) \
976-
LCALLNAMES(A, B, 2) LCALLNAMES(A, B, 4) LCALLNAMES(A, B, 8)
977-
#define LCALLNAME5(A, B) \
978-
LCALLNAMES(A, B, 1) \
979-
LCALLNAMES(A, B, 2) \
980-
LCALLNAMES(A, B, 4) LCALLNAMES(A, B, 8) LCALLNAMES(A, B, 16)
981-
LCALLNAME5(RTLIB::OUTLINE_ATOMIC_CAS, __aarch64_cas)
982-
LCALLNAME4(RTLIB::OUTLINE_ATOMIC_SWP, __aarch64_swp)
983-
LCALLNAME4(RTLIB::OUTLINE_ATOMIC_LDADD, __aarch64_ldadd)
984-
LCALLNAME4(RTLIB::OUTLINE_ATOMIC_LDSET, __aarch64_ldset)
985-
LCALLNAME4(RTLIB::OUTLINE_ATOMIC_LDCLR, __aarch64_ldclr)
986-
LCALLNAME4(RTLIB::OUTLINE_ATOMIC_LDEOR, __aarch64_ldeor)
987-
#undef LCALLNAMES
988-
#undef LCALLNAME4
989-
#undef LCALLNAME5
990969
}
991970

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

0 commit comments

Comments
 (0)