Prepend all library intrinsics with # when building for Arm64EC#87542
Conversation
|
@llvm/pr-subscribers-backend-aarch64 Author: Daniel Paoliello (dpaoliello) ChangesWhile attempting to build some Rust code, I was getting linker errors due to missing functions that are implemented in This change removes the hard-coded list of library-implemented intrinsics to mangle for Arm64EC, and instead assumes that they all must be mangled. Full diff: https://github.com/llvm/llvm-project/pull/87542.diff 1 Files Affected:
diff --git a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
index 8218960406ec13..7fe81911556a22 100644
--- a/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ b/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -1716,40 +1716,21 @@ AArch64TargetLowering::AArch64TargetLowering(const TargetMachine &TM,
setMaxAtomicSizeInBitsSupported(128);
if (Subtarget->isWindowsArm64EC()) {
- // FIXME: are there other intrinsics we need to add here?
- setLibcallName(RTLIB::MEMCPY, "#memcpy");
- setLibcallName(RTLIB::MEMSET, "#memset");
- setLibcallName(RTLIB::MEMMOVE, "#memmove");
- setLibcallName(RTLIB::REM_F32, "#fmodf");
- setLibcallName(RTLIB::REM_F64, "#fmod");
- setLibcallName(RTLIB::FMA_F32, "#fmaf");
- setLibcallName(RTLIB::FMA_F64, "#fma");
- setLibcallName(RTLIB::SQRT_F32, "#sqrtf");
- setLibcallName(RTLIB::SQRT_F64, "#sqrt");
- setLibcallName(RTLIB::CBRT_F32, "#cbrtf");
- setLibcallName(RTLIB::CBRT_F64, "#cbrt");
- setLibcallName(RTLIB::LOG_F32, "#logf");
- setLibcallName(RTLIB::LOG_F64, "#log");
- setLibcallName(RTLIB::LOG2_F32, "#log2f");
- setLibcallName(RTLIB::LOG2_F64, "#log2");
- setLibcallName(RTLIB::LOG10_F32, "#log10f");
- setLibcallName(RTLIB::LOG10_F64, "#log10");
- setLibcallName(RTLIB::EXP_F32, "#expf");
- setLibcallName(RTLIB::EXP_F64, "#exp");
- setLibcallName(RTLIB::EXP2_F32, "#exp2f");
- setLibcallName(RTLIB::EXP2_F64, "#exp2");
- setLibcallName(RTLIB::EXP10_F32, "#exp10f");
- setLibcallName(RTLIB::EXP10_F64, "#exp10");
- setLibcallName(RTLIB::SIN_F32, "#sinf");
- setLibcallName(RTLIB::SIN_F64, "#sin");
- setLibcallName(RTLIB::COS_F32, "#cosf");
- setLibcallName(RTLIB::COS_F64, "#cos");
- setLibcallName(RTLIB::POW_F32, "#powf");
- setLibcallName(RTLIB::POW_F64, "#pow");
- setLibcallName(RTLIB::LDEXP_F32, "#ldexpf");
- setLibcallName(RTLIB::LDEXP_F64, "#ldexp");
- setLibcallName(RTLIB::FREXP_F32, "#frexpf");
- setLibcallName(RTLIB::FREXP_F64, "#frexp");
+ // FIXME: are there intrinsics we need to exclude from this?
+ for (int i = 0; i < RTLIB::UNKNOWN_LIBCALL; ++i) {
+ auto code = static_cast<RTLIB::Libcall>(i);
+ auto libcallName = getLibcallName(code);
+ if ((libcallName != nullptr) && (libcallName[0] != '#')) {
+ // Note that this is a leak, but since nothing should be modifying the
+ // libcall names after this point these allocations should last until
+ // the end of the process.
+ auto len = strlen(libcallName);
+ auto newLibcallName = new char[len + 2];
+ newLibcallName[0] = '#';
+ memcpy(newLibcallName + 1, libcallName, len + 1);
+ setLibcallName(code, newLibcallName);
+ }
+ }
}
}
|
e522b56 to
a41d3d4
Compare
a41d3d4 to
972c264
Compare
|
@efriedma-quic I think this is ready to land, any additional comments? |
efriedma-quic
left a comment
There was a problem hiding this comment.
LGTM, but we should probably look at adding more test coverage for this as a followup.
…vm#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.
…vm#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.
…vm#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.
|
Missing tests |
…vm#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.
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 whencompiler-rtis 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.