https://github.com/arsenm updated https://github.com/llvm/llvm-project/pull/143082
>From 67d040367f97806e16a658acff3427aa2396e8e4 Mon Sep 17 00:00:00 2001 From: Matt Arsenault <matthew.arsena...@amd.com> Date: Fri, 6 Jun 2025 14:50:57 +0900 Subject: [PATCH 1/3] RuntimeLibcalls: Use array initializers for default values --- llvm/include/llvm/IR/RuntimeLibcalls.h | 8 +++++--- llvm/lib/IR/RuntimeLibcalls.cpp | 10 ---------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.h b/llvm/include/llvm/IR/RuntimeLibcalls.h index 6d8f007136153..c98a63a41d2bd 100644 --- a/llvm/include/llvm/IR/RuntimeLibcalls.h +++ b/llvm/include/llvm/IR/RuntimeLibcalls.h @@ -103,10 +103,11 @@ struct RuntimeLibcallsInfo { private: /// Stores the name each libcall. - const char *LibcallRoutineNames[RTLIB::UNKNOWN_LIBCALL + 1]; + const char *LibcallRoutineNames[RTLIB::UNKNOWN_LIBCALL + 1] = {nullptr}; /// Stores the CallingConv that should be used for each libcall. - CallingConv::ID LibcallCallingConvs[RTLIB::UNKNOWN_LIBCALL]; + CallingConv::ID LibcallCallingConvs[RTLIB::UNKNOWN_LIBCALL] = { + CallingConv::C}; /// The condition type that should be used to test the result of each of the /// soft floating-point comparison libcall against integer zero. @@ -114,7 +115,8 @@ struct RuntimeLibcallsInfo { // FIXME: This is only relevant for the handful of floating-point comparison // runtime calls; it's excessive to have a table entry for every single // opcode. - CmpInst::Predicate SoftFloatCompareLibcallPredicates[RTLIB::UNKNOWN_LIBCALL]; + CmpInst::Predicate SoftFloatCompareLibcallPredicates[RTLIB::UNKNOWN_LIBCALL] = + {CmpInst::BAD_ICMP_PREDICATE}; static bool darwinHasSinCosStret(const Triple &TT) { assert(TT.isOSDarwin() && "should be called with darwin triple"); diff --git a/llvm/lib/IR/RuntimeLibcalls.cpp b/llvm/lib/IR/RuntimeLibcalls.cpp index 7c0ffe170e196..b85a878887dec 100644 --- a/llvm/lib/IR/RuntimeLibcalls.cpp +++ b/llvm/lib/IR/RuntimeLibcalls.cpp @@ -12,9 +12,6 @@ using namespace llvm; using namespace RTLIB; void RuntimeLibcallsInfo::initSoftFloatCmpLibcallPredicates() { - std::fill(SoftFloatCompareLibcallPredicates, - SoftFloatCompareLibcallPredicates + RTLIB::UNKNOWN_LIBCALL, - CmpInst::BAD_ICMP_PREDICATE); SoftFloatCompareLibcallPredicates[RTLIB::OEQ_F32] = CmpInst::ICMP_EQ; SoftFloatCompareLibcallPredicates[RTLIB::OEQ_F64] = CmpInst::ICMP_EQ; SoftFloatCompareLibcallPredicates[RTLIB::OEQ_F128] = CmpInst::ICMP_EQ; @@ -48,19 +45,12 @@ void RuntimeLibcallsInfo::initSoftFloatCmpLibcallPredicates() { /// Set default libcall names. If a target wants to opt-out of a libcall it /// should be placed here. void RuntimeLibcallsInfo::initLibcalls(const Triple &TT) { - std::fill(std::begin(LibcallRoutineNames), std::end(LibcallRoutineNames), - nullptr); - initSoftFloatCmpLibcallPredicates(); #define HANDLE_LIBCALL(code, name) setLibcallName(RTLIB::code, name); #include "llvm/IR/RuntimeLibcalls.def" #undef HANDLE_LIBCALL - // Initialize calling conventions to their default. - for (int LC = 0; LC < RTLIB::UNKNOWN_LIBCALL; ++LC) - setLibcallCallingConv((RTLIB::Libcall)LC, CallingConv::C); - // Use the f128 variants of math functions on x86 if (TT.isX86() && TT.isGNUEnvironment()) { setLibcallName(RTLIB::REM_F128, "fmodf128"); >From f991879aeb7fc4c3f30dd142154bb2f063acaaa0 Mon Sep 17 00:00:00 2001 From: Matt Arsenault <matthew.arsena...@amd.com> Date: Fri, 6 Jun 2025 22:59:15 +0900 Subject: [PATCH 2/3] Revert for compare predicate case --- llvm/include/llvm/IR/RuntimeLibcalls.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.h b/llvm/include/llvm/IR/RuntimeLibcalls.h index c98a63a41d2bd..bf29b03a18ab2 100644 --- a/llvm/include/llvm/IR/RuntimeLibcalls.h +++ b/llvm/include/llvm/IR/RuntimeLibcalls.h @@ -105,6 +105,9 @@ struct RuntimeLibcallsInfo { /// Stores the name each libcall. const char *LibcallRoutineNames[RTLIB::UNKNOWN_LIBCALL + 1] = {nullptr}; + static_assert(static_cast<int>(CallingConv::C) == 0, + "default calling conv should be encoded as 0"); + /// Stores the CallingConv that should be used for each libcall. CallingConv::ID LibcallCallingConvs[RTLIB::UNKNOWN_LIBCALL] = { CallingConv::C}; @@ -115,8 +118,7 @@ struct RuntimeLibcallsInfo { // FIXME: This is only relevant for the handful of floating-point comparison // runtime calls; it's excessive to have a table entry for every single // opcode. - CmpInst::Predicate SoftFloatCompareLibcallPredicates[RTLIB::UNKNOWN_LIBCALL] = - {CmpInst::BAD_ICMP_PREDICATE}; + CmpInst::Predicate SoftFloatCompareLibcallPredicates[RTLIB::UNKNOWN_LIBCALL]; static bool darwinHasSinCosStret(const Triple &TT) { assert(TT.isOSDarwin() && "should be called with darwin triple"); >From 540bdadf7797f30b41daa847c8f5d9d985a79954 Mon Sep 17 00:00:00 2001 From: Matt Arsenault <matthew.arsena...@amd.com> Date: Sat, 7 Jun 2025 01:54:36 +0900 Subject: [PATCH 3/3] Update llvm/include/llvm/IR/RuntimeLibcalls.h --- llvm/include/llvm/IR/RuntimeLibcalls.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.h b/llvm/include/llvm/IR/RuntimeLibcalls.h index bf29b03a18ab2..165bbf6c2178e 100644 --- a/llvm/include/llvm/IR/RuntimeLibcalls.h +++ b/llvm/include/llvm/IR/RuntimeLibcalls.h @@ -109,8 +109,7 @@ struct RuntimeLibcallsInfo { "default calling conv should be encoded as 0"); /// Stores the CallingConv that should be used for each libcall. - CallingConv::ID LibcallCallingConvs[RTLIB::UNKNOWN_LIBCALL] = { - CallingConv::C}; + CallingConv::ID LibcallCallingConvs[RTLIB::UNKNOWN_LIBCALL] = {}; /// The condition type that should be used to test the result of each of the /// soft floating-point comparison libcall against integer zero. _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits