Skip to content

Commit 4056cc2

Browse files
dpaoliellotstellar
authored andcommitted
Prepend all library intrinsics with # when building for Arm64EC (#87542)
While attempting to build some Rust code, I was getting linker errors due to missing functions that are implemented in `compiler-rt`. Turns out that when `compiler-rt` is built for Arm64EC, all its function names are mangled with the leading `#`. This change removes the hard-coded list of library-implemented intrinsics to mangle for Arm64EC, and instead assumes that they all must be mangled.
1 parent 6e071cf commit 4056cc2

File tree

2 files changed

+11
-34
lines changed

2 files changed

+11
-34
lines changed

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

+8-34
Original file line numberDiff line numberDiff line change
@@ -1658,40 +1658,14 @@ AArch64TargetLowering::AArch64TargetLowering(const TargetMachine &TM,
16581658
setMaxAtomicSizeInBitsSupported(128);
16591659

16601660
if (Subtarget->isWindowsArm64EC()) {
1661-
// FIXME: are there other intrinsics we need to add here?
1662-
setLibcallName(RTLIB::MEMCPY, "#memcpy");
1663-
setLibcallName(RTLIB::MEMSET, "#memset");
1664-
setLibcallName(RTLIB::MEMMOVE, "#memmove");
1665-
setLibcallName(RTLIB::REM_F32, "#fmodf");
1666-
setLibcallName(RTLIB::REM_F64, "#fmod");
1667-
setLibcallName(RTLIB::FMA_F32, "#fmaf");
1668-
setLibcallName(RTLIB::FMA_F64, "#fma");
1669-
setLibcallName(RTLIB::SQRT_F32, "#sqrtf");
1670-
setLibcallName(RTLIB::SQRT_F64, "#sqrt");
1671-
setLibcallName(RTLIB::CBRT_F32, "#cbrtf");
1672-
setLibcallName(RTLIB::CBRT_F64, "#cbrt");
1673-
setLibcallName(RTLIB::LOG_F32, "#logf");
1674-
setLibcallName(RTLIB::LOG_F64, "#log");
1675-
setLibcallName(RTLIB::LOG2_F32, "#log2f");
1676-
setLibcallName(RTLIB::LOG2_F64, "#log2");
1677-
setLibcallName(RTLIB::LOG10_F32, "#log10f");
1678-
setLibcallName(RTLIB::LOG10_F64, "#log10");
1679-
setLibcallName(RTLIB::EXP_F32, "#expf");
1680-
setLibcallName(RTLIB::EXP_F64, "#exp");
1681-
setLibcallName(RTLIB::EXP2_F32, "#exp2f");
1682-
setLibcallName(RTLIB::EXP2_F64, "#exp2");
1683-
setLibcallName(RTLIB::EXP10_F32, "#exp10f");
1684-
setLibcallName(RTLIB::EXP10_F64, "#exp10");
1685-
setLibcallName(RTLIB::SIN_F32, "#sinf");
1686-
setLibcallName(RTLIB::SIN_F64, "#sin");
1687-
setLibcallName(RTLIB::COS_F32, "#cosf");
1688-
setLibcallName(RTLIB::COS_F64, "#cos");
1689-
setLibcallName(RTLIB::POW_F32, "#powf");
1690-
setLibcallName(RTLIB::POW_F64, "#pow");
1691-
setLibcallName(RTLIB::LDEXP_F32, "#ldexpf");
1692-
setLibcallName(RTLIB::LDEXP_F64, "#ldexp");
1693-
setLibcallName(RTLIB::FREXP_F32, "#frexpf");
1694-
setLibcallName(RTLIB::FREXP_F64, "#frexp");
1661+
// FIXME: are there intrinsics we need to exclude from this?
1662+
for (int i = 0; i < RTLIB::UNKNOWN_LIBCALL; ++i) {
1663+
auto code = static_cast<RTLIB::Libcall>(i);
1664+
auto libcallName = getLibcallName(code);
1665+
if ((libcallName != nullptr) && (libcallName[0] != '#')) {
1666+
setLibcallName(code, Saver.save(Twine("#") + libcallName).data());
1667+
}
1668+
}
16951669
}
16961670
}
16971671

llvm/lib/Target/AArch64/AArch64ISelLowering.h

+3
Original file line numberDiff line numberDiff line change
@@ -1001,6 +1001,9 @@ class AArch64TargetLowering : public TargetLowering {
10011001
/// make the right decision when generating code for different targets.
10021002
const AArch64Subtarget *Subtarget;
10031003

1004+
llvm::BumpPtrAllocator BumpAlloc;
1005+
llvm::StringSaver Saver{BumpAlloc};
1006+
10041007
bool isExtFreeImpl(const Instruction *Ext) const override;
10051008

10061009
void addTypeForNEON(MVT VT);

0 commit comments

Comments
 (0)