llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-llvm-ir Author: Matt Arsenault (arsenm) <details> <summary>Changes</summary> The __atomic_* functions are not part of libgcc or the default compiler-rt builtins. GCC ships them in libatomic, and compiler-rt in the optional clang_rt.atomic. Every system that uses compiler-rt also lists libatomic, so the available functions are unchanged. Co-authored-by: Claude Opus 5.5 <noreply@<!-- -->anthropic.com> --- Full diff: https://github.com/llvm/llvm-project/pull/233571.diff 2 Files Affected: - (modified) llvm/include/llvm/IR/RuntimeLibcalls.td (+51-20) - (modified) llvm/unittests/IR/RuntimeLibcallsTest.cpp (+11-9) ``````````diff diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.td b/llvm/include/llvm/IR/RuntimeLibcalls.td index dd6348f3b3a50..2523d11d35f87 100644 --- a/llvm/include/llvm/IR/RuntimeLibcalls.td +++ b/llvm/include/llvm/IR/RuntimeLibcalls.td @@ -1391,11 +1391,6 @@ foreach lc = LibCalls__sync in { def __#!tolower(!cast<string>(lc)) : RuntimeLibcallImpl<lc>; } -// Atomic `__atomic_*' libcalls. -foreach lc = LibCalls__atomic in { - def __#!tolower(!cast<string>(lc)) : RuntimeLibcallImpl<lc>; -} - // Deoptimization def __llvm_deoptimize : RuntimeLibcallImpl<DEOPTIMIZE>; @@ -1403,6 +1398,16 @@ def __llvm_deoptimize : RuntimeLibcallImpl<DEOPTIMIZE>; def __clear_cache : RuntimeLibcallImpl<CLEAR_CACHE>; } // End defset CompilerRtLibgccImpls +// libatomic +//-------------------------------------------------------------------- + +// Atomic `__atomic_*' libcalls. +defset list<RuntimeLibcallImpl> LibatomicImpls = { + foreach lc = LibCalls__atomic in { + def __#!tolower(!cast<string>(lc)) : RuntimeLibcallImpl<lc>; + } +} + //-------------------------------------------------------------------- // libm //-------------------------------------------------------------------- @@ -2214,6 +2219,9 @@ def CompilerRtLibgcc : LibcallLibrary<"compiler-rt", LibcallImpls<(add CompilerRtLibgccImpls_ppcf128), isLongDoublePPCF128>, LibcallImpls<(add Int128RTLibcalls), isArch64Bit>)>; +// The `__atomic_*' runtime: GCC's libatomic, or compiler-rt's clang_rt.atomic. +def Libatomic : LibcallLibrary<"libatomic", (add LibatomicImpls)>; + def Libc : LibcallLibrary<"libc", (add LibcCoreImpls)>; // PPC and SPARC provide their own stack protector, and XCore has none. @@ -2356,7 +2364,7 @@ def AArch64OutlineAtomics : LibcallLibrary<"compiler-rt", isAArch64_ExceptArm64EC>; def AArch64SystemLibrary : SystemRuntimeLibrary<isAArch64_ExceptArm64EC, - ["compiler-rt", "libm", "libc", "unwind", "sme"]>; + ["compiler-rt", "libatomic", "libm", "libc", "unwind", "sme"]>; // The Windows runtime lacks the f32 and f64 powi helpers, and frexpf/ldexpf. defvar Arm64ECCompilerRtImpls = @@ -2376,6 +2384,12 @@ defset list<RuntimeLibcallImpl> WinArm64ECDefaultRuntimeLibcallImpls = { } } +defset list<RuntimeLibcallImpl> WinArm64ECLibatomicImpls = { + foreach libcall = LibatomicImpls in { + def arm64ec_#libcall : DuplicateLibcallImplWithPrefix<libcall, "#">; + } +} + def arm64ec___stack_chk_fail : DuplicateLibcallImplWithPrefix<__stack_chk_fail, "#">; defset list<RuntimeLibcallImpl> WinArm64ECDefaultExceptionHandlingLibcalls = { @@ -2423,9 +2437,14 @@ def Arm64ECRuntime : LibcallLibrary<"compiler-rt", let Isolated = true; } +def Arm64ECLibatomic : LibcallLibrary<"libatomic", + (add WinArm64ECLibatomicImpls), isWindowsArm64EC> { + let Isolated = true; +} + def WindowsARM64ECSystemLibrary : SystemRuntimeLibrary<isWindowsArm64EC, - ["compiler-rt", "libc", "unwind"]>; + ["compiler-rt", "libatomic", "libc", "unwind"]>; //===----------------------------------------------------------------------===// // AMDGPU Runtime Libcalls @@ -2910,7 +2929,7 @@ def ARMLibm : LibcallLibrary<"libm", def ARMSystemLibrary : SystemRuntimeLibrary<isARMOrThumb, - ["compiler-rt", "libm", "libc", "unwind"]> { + ["compiler-rt", "libatomic", "libm", "libc", "unwind"]> { let DefaultLibcallCallingConv = LibcallCallingConv<[{ TT.isOSDarwin() ? CallingConv::C : (FloatABI == FloatABI::Hard ? CallingConv::ARM_AAPCS_VFP @@ -2960,7 +2979,8 @@ defvar AVRCompilerRtOptOut = [ defvar AVRLibmOptOut = [sin, cos, sinf, cosf, sincos, sincosf]; def AVRSystemLibrary - : SystemRuntimeLibrary<isAVR, ["compiler-rt", "libm", "libc", "unwind"]>; + : SystemRuntimeLibrary<isAVR, ["compiler-rt", "libatomic", "libm", + "libc", "unwind"]>; def : LibraryExclusion<"compiler-rt", isAVR, AVRCompilerRtOptOut>; def : LibraryExclusion<"libm", isAVR, AVRLibmOptOut>; @@ -3026,7 +3046,8 @@ def HexagonCompilerRt def HexagonSystemLibrary : SystemRuntimeLibrary<isHexagon, - ["compiler-rt", "libm", "libc", "unwind"]>; + ["compiler-rt", "libatomic", "libm", + "libc", "unwind"]>; //===----------------------------------------------------------------------===// // Lanai Runtime Libcalls @@ -3037,7 +3058,8 @@ def isLanai : RuntimeLibcallAvailability<(all_of IsLanai)>; // Use fast calling convention for library functions. def LanaiSystemLibrary : SystemRuntimeLibrary<isLanai, - ["compiler-rt", "libm", "libc", "unwind"]> { + ["compiler-rt", "libatomic", "libm", + "libc", "unwind"]> { let DefaultLibcallCallingConv = FASTCC; } @@ -3310,7 +3332,8 @@ def MSP430CompilerRt : LibcallLibrary<"compiler-rt", (add def MSP430SystemLibrary : SystemRuntimeLibrary<isMSP430, - ["compiler-rt", "libm", "libc", "unwind"]>; + ["compiler-rt", "libatomic", "libm", + "libc", "unwind"]>; def : LibraryExclusion<"compiler-rt", isMSP430, MSP430DefaultOptOut>; def : LibraryExclusion<"libm", isMSP430, [sincos, sincosf]>; @@ -3433,7 +3456,8 @@ defvar PPCReplacedCompilerRtF128 = [ __powitf2_f128, __trunctfhf2_f128]; def PPCSystemLibrary - : SystemRuntimeLibrary<isPPC, ["compiler-rt", "libc", "libm", "unwind"]>; + : SystemRuntimeLibrary<isPPC, ["compiler-rt", "libatomic", "libc", + "libm", "unwind"]>; def : LibraryExclusion<"compiler-rt", isPPC, PPCReplacedCompilerRtF128>; def : LibraryExclusion<"libc", isPPC, [memcpy]>; @@ -3449,7 +3473,8 @@ def RISCVLibc : LibcallLibrary<"libc", (add __riscv_flush_icache), isRISCV>; def RISCVSystemLibrary : SystemRuntimeLibrary<isRISCV, - ["compiler-rt", "libm", "libc", "unwind"]>; + ["compiler-rt", "libatomic", "libm", + "libc", "unwind"]>; //===----------------------------------------------------------------------===// // SPARC Runtime Libcalls @@ -3523,7 +3548,8 @@ def SPARCStackProtectorLibc : LibcallLibrary<"libc", def SPARCSystemLibrary : SystemRuntimeLibrary<isSPARC, - ["compiler-rt", "libm", "libc", "unwind"]>; + ["compiler-rt", "libatomic", "libm", + "libc", "unwind"]>; def : LibraryExclusion<"compiler-rt", isSPARC, SPARC64_MulDivCalls>; @@ -3621,7 +3647,8 @@ def X86Libm : LibcallLibrary<"libm", LibcallImpls<(add frexpl_f128, ldexpl_f128), isLongDoubleF128>), isX86>; def X86SystemLibrary - : SystemRuntimeLibrary<isX86, ["compiler-rt", "libm", "libc", "unwind"]>; + : SystemRuntimeLibrary<isX86, ["compiler-rt", "libatomic", "libm", + "libc", "unwind"]>; def : LibraryExclusion<"compiler-rt", isX86, !listconcat(WindowsDivRemMulLibcallOverrides, [__powitf2_f128])>; @@ -3647,7 +3674,8 @@ def XCoreLibm : LibcallLibrary<"libm", def XCoreSystemLibrary : SystemRuntimeLibrary<isXCore, - ["compiler-rt", "libm", "libc", "unwind"]>; + ["compiler-rt", "libatomic", "libm", + "libc", "unwind"]>; def : LibraryExclusion<"libm", isXCore, [sincos, sincosf]>; @@ -3769,7 +3797,8 @@ def ZOSLibc : LibcallLibrary<"libc", (add ZOSRuntimeLibcalls), isSystemZZOS>; def SystemZZOSSystemLibrary : SystemRuntimeLibrary<isSystemZZOS, - ["compiler-rt", "libm", "libc", "unwind"]>; + ["compiler-rt", "libatomic", "libm", + "libc", "unwind"]>; //===----------------------------------------------------------------------===// // WebAssembly Runtime Libcalls @@ -3800,7 +3829,8 @@ def WasmExceptionRuntime : LibcallLibrary<"unwind", (add _Unwind_GetWasmLPadContext), isWasm>; def WasmSystemLibrary - : SystemRuntimeLibrary<isWasm, ["compiler-rt", "libm", "libc", "unwind"]>; + : SystemRuntimeLibrary<isWasm, ["compiler-rt", "libatomic", "libm", + "libc", "unwind"]>; def : LibraryExclusion<"libm", isWasm, [sincos, sincosf, sincosl_f128]>; @@ -3816,7 +3846,8 @@ def isDefaultLibcallArch : RuntimeLibcallAvailability< def LegacyDefaultSystemLibrary : SystemRuntimeLibrary<isDefaultLibcallArch, - ["compiler-rt", "libm", "libc", "unwind"]>; + ["compiler-rt", "libatomic", "libm", + "libc", "unwind"]>; //===----------------------------------------------------------------------===// // Vector math libraries diff --git a/llvm/unittests/IR/RuntimeLibcallsTest.cpp b/llvm/unittests/IR/RuntimeLibcallsTest.cpp index 012310e9b1de8..43836ae9bd68c 100644 --- a/llvm/unittests/IR/RuntimeLibcallsTest.cpp +++ b/llvm/unittests/IR/RuntimeLibcallsTest.cpp @@ -67,18 +67,20 @@ TEST(RuntimeLibcallsTest, LibcallImplByName) { TEST(RuntimeLibcallsTest, DefaultRuntimeLibraries) { using Info = RTLIB::RuntimeLibcallsInfo; const RTLIB::RuntimeLibrary X86Libs[] = { - RTLIB::RuntimeLibrary::compiler_rt, RTLIB::RuntimeLibrary::libc, - RTLIB::RuntimeLibrary::libm, RTLIB::RuntimeLibrary::unwind}; - const RTLIB::RuntimeLibrary AArch64Libs[] = { - RTLIB::RuntimeLibrary::compiler_rt, RTLIB::RuntimeLibrary::libc, - RTLIB::RuntimeLibrary::libm, RTLIB::RuntimeLibrary::sme, + RTLIB::RuntimeLibrary::compiler_rt, RTLIB::RuntimeLibrary::libatomic, + RTLIB::RuntimeLibrary::libc, RTLIB::RuntimeLibrary::libm, RTLIB::RuntimeLibrary::unwind}; + const RTLIB::RuntimeLibrary AArch64Libs[] = { + RTLIB::RuntimeLibrary::compiler_rt, RTLIB::RuntimeLibrary::libatomic, + RTLIB::RuntimeLibrary::libc, RTLIB::RuntimeLibrary::libm, + RTLIB::RuntimeLibrary::sme, RTLIB::RuntimeLibrary::unwind}; const RTLIB::RuntimeLibrary Arm64ECLibs[] = { - RTLIB::RuntimeLibrary::compiler_rt, RTLIB::RuntimeLibrary::libc, - RTLIB::RuntimeLibrary::unwind}; + RTLIB::RuntimeLibrary::compiler_rt, RTLIB::RuntimeLibrary::libatomic, + RTLIB::RuntimeLibrary::libc, RTLIB::RuntimeLibrary::unwind}; const RTLIB::RuntimeLibrary PPCLibs[] = { - RTLIB::RuntimeLibrary::compiler_rt, RTLIB::RuntimeLibrary::libc, - RTLIB::RuntimeLibrary::libm, RTLIB::RuntimeLibrary::unwind}; + RTLIB::RuntimeLibrary::compiler_rt, RTLIB::RuntimeLibrary::libatomic, + RTLIB::RuntimeLibrary::libc, RTLIB::RuntimeLibrary::libm, + RTLIB::RuntimeLibrary::unwind}; const RTLIB::RuntimeLibrary AMDGPULibs[] = { RTLIB::RuntimeLibrary::compiler_rt_profile}; const RTLIB::RuntimeLibrary SPIRVLibs[] = {RTLIB::RuntimeLibrary::libc}; `````````` </details> https://github.com/llvm/llvm-project/pull/233571 _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
