[llvm] RuntimeLibcalls: Split lowering decisions into LibcallLoweringInfo (PR #164987)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 5 08:32:48 PST 2025
https://github.com/arsenm updated https://github.com/llvm/llvm-project/pull/164987
>From aa36f2bb1fb20b5b0f9e6a41e6e90af925855b2f Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Tue, 7 Oct 2025 20:00:23 +0900
Subject: [PATCH 1/6] RuntimeLibcalls: Split lowering decisions into
LibcallLoweringInfo
Introduce a new class for the TargetLowering usage. This tracks the
subtarget specific lowering decisions for which libcall to use.
RuntimeLibcallsInfo is a module level property, which may have multiple
implementations of a particular libcall available. This attempts to be
a minimum boilerplate patch to introduce the new concept.
In the future we should have a tablegen way of selecting which
implementations should be used for a subtarget. Currently we
do have some conflicting implementations added, it just happens
to work out that the default cases to prefer is alphabetically
first (plus some of these still are using manual overrides
in TargetLowering constructors).
---
llvm/include/llvm/CodeGen/TargetLowering.h | 70 ++++++++++++++---
llvm/include/llvm/IR/RuntimeLibcalls.h | 52 ++++---------
llvm/lib/CodeGen/TargetLoweringBase.cpp | 23 +++++-
llvm/lib/IR/RuntimeLibcalls.cpp | 1 +
llvm/lib/LTO/LTO.cpp | 7 +-
.../WebAssemblyRuntimeLibcallSignatures.cpp | 20 +++--
.../Utils/DeclareRuntimeLibcalls.cpp | 4 +-
.../RuntimeLibcallEmitter-calling-conv.td | 60 +++++++-------
.../RuntimeLibcallEmitter-conflict-warning.td | 30 +++----
llvm/test/TableGen/RuntimeLibcallEmitter.td | 78 +++++++++----------
.../Util/DeclareRuntimeLibcalls/basic.ll | 9 ++-
.../TableGen/Basic/RuntimeLibcallsEmitter.cpp | 19 ++---
12 files changed, 209 insertions(+), 164 deletions(-)
diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h b/llvm/include/llvm/CodeGen/TargetLowering.h
index b229659415d55..d8ec8441dd565 100644
--- a/llvm/include/llvm/CodeGen/TargetLowering.h
+++ b/llvm/include/llvm/CodeGen/TargetLowering.h
@@ -193,6 +193,58 @@ struct MemOp {
}
};
+class LibcallLoweringInfo {
+private:
+ LLVM_ABI const RTLIB::RuntimeLibcallsInfo &RTLCI;
+ /// Stores the implementation choice for each each libcall.
+ LLVM_ABI RTLIB::LibcallImpl LibcallImpls[RTLIB::UNKNOWN_LIBCALL + 1] = {
+ RTLIB::Unsupported};
+
+public:
+ LLVM_ABI LibcallLoweringInfo(const RTLIB::RuntimeLibcallsInfo &RTLCI);
+
+ /// Get the libcall routine name for the specified libcall.
+ // FIXME: This should be removed. Only LibcallImpl should have a name.
+ LLVM_ABI const char *getLibcallName(RTLIB::Libcall Call) const {
+ // FIXME: Return StringRef
+ return RTLIB::RuntimeLibcallsInfo::getLibcallImplName(LibcallImpls[Call])
+ .data();
+ }
+
+ /// Return the lowering's selection of implementation call for \p Call
+ LLVM_ABI RTLIB::LibcallImpl getLibcallImpl(RTLIB::Libcall Call) const {
+ return LibcallImpls[Call];
+ }
+
+ /// Rename the default libcall routine name for the specified libcall.
+ LLVM_ABI void setLibcallImpl(RTLIB::Libcall Call, RTLIB::LibcallImpl Impl) {
+ LibcallImpls[Call] = Impl;
+ }
+
+ // FIXME: Remove this wrapper in favor of directly using
+ // getLibcallImplCallingConv
+ LLVM_ABI CallingConv::ID getLibcallCallingConv(RTLIB::Libcall Call) const {
+ return RTLCI.LibcallImplCallingConvs[LibcallImpls[Call]];
+ }
+
+ /// Get the CallingConv that should be used for the specified libcall.
+ LLVM_ABI CallingConv::ID
+ getLibcallImplCallingConv(RTLIB::LibcallImpl Call) const {
+ return RTLCI.LibcallImplCallingConvs[Call];
+ }
+
+ /// Return a function name compatible with RTLIB::MEMCPY, or nullptr if fully
+ /// unsupported.
+ LLVM_ABI StringRef getMemcpyName() const {
+ RTLIB::LibcallImpl Memcpy = getLibcallImpl(RTLIB::MEMCPY);
+ if (Memcpy != RTLIB::Unsupported)
+ return RTLIB::RuntimeLibcallsInfo::getLibcallImplName(Memcpy);
+
+ // Fallback to memmove if memcpy isn't available.
+ return getLibcallName(RTLIB::MEMMOVE);
+ }
+};
+
/// This base class for TargetLowering contains the SelectionDAG-independent
/// parts that can be used from the rest of CodeGen.
class LLVM_ABI TargetLoweringBase {
@@ -3597,7 +3649,7 @@ class LLVM_ABI TargetLoweringBase {
}
const RTLIB::RuntimeLibcallsInfo &getRuntimeLibcallsInfo() const {
- return Libcalls;
+ return RuntimeLibcallInfo;
}
void setLibcallImpl(RTLIB::Libcall Call, RTLIB::LibcallImpl Impl) {
@@ -3610,9 +3662,9 @@ class LLVM_ABI TargetLoweringBase {
}
/// Get the libcall routine name for the specified libcall.
+ // FIXME: This should be removed. Only LibcallImpl should have a name.
const char *getLibcallName(RTLIB::Libcall Call) const {
- // FIXME: Return StringRef
- return Libcalls.getLibcallName(Call).data();
+ return Libcalls.getLibcallName(Call);
}
/// Get the libcall routine name for the specified libcall implementation
@@ -3625,7 +3677,7 @@ class LLVM_ABI TargetLoweringBase {
/// Check if this is valid libcall for the current module, otherwise
/// RTLIB::Unsupported.
RTLIB::LibcallImpl getSupportedLibcallImpl(StringRef FuncName) const {
- return Libcalls.getSupportedLibcallImpl(FuncName);
+ return RuntimeLibcallInfo.getSupportedLibcallImpl(FuncName);
}
/// Get the comparison predicate that's to be used to test the result of the
@@ -3633,11 +3685,6 @@ class LLVM_ABI TargetLoweringBase {
/// floating-point compare libcalls.
ISD::CondCode getSoftFloatCmpLibcallPredicate(RTLIB::LibcallImpl Call) const;
- /// Set the CallingConv that should be used for the specified libcall.
- void setLibcallImplCallingConv(RTLIB::LibcallImpl Call, CallingConv::ID CC) {
- Libcalls.setLibcallImplCallingConv(Call, CC);
- }
-
/// Get the CallingConv that should be used for the specified libcall
/// implementation.
CallingConv::ID getLibcallImplCallingConv(RTLIB::LibcallImpl Call) const {
@@ -3834,8 +3881,11 @@ class LLVM_ABI TargetLoweringBase {
std::map<std::pair<unsigned, MVT::SimpleValueType>, MVT::SimpleValueType>
PromoteToType;
+ /// FIXME: This should not live here; it should come from an analysis.
+ const RTLIB::RuntimeLibcallsInfo RuntimeLibcallInfo;
+
/// The list of libcalls that the target will use.
- RTLIB::RuntimeLibcallsInfo Libcalls;
+ LibcallLoweringInfo Libcalls;
/// The bits of IndexedModeActions used to store the legalisation actions
/// We store the data as | ML | MS | L | S | each taking 4 bits.
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.h b/llvm/include/llvm/IR/RuntimeLibcalls.h
index bae760b3f981d..8df94ffb980b6 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.h
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.h
@@ -34,6 +34,8 @@
namespace llvm {
+class LibcallLoweringInfo;
+
template <> struct enum_iteration_traits<RTLIB::Libcall> {
static constexpr bool is_iterable = true;
};
@@ -70,6 +72,8 @@ struct RuntimeLibcallsInfo {
LibcallImplBitset AvailableLibcallImpls;
public:
+ friend class llvm::LibcallLoweringInfo;
+
explicit RuntimeLibcallsInfo(
const Triple &TT,
ExceptionHandling ExceptionModel = ExceptionHandling::None,
@@ -85,17 +89,6 @@ struct RuntimeLibcallsInfo {
initLibcalls(TT, ExceptionModel, FloatABI, EABIVersion, ABIName);
}
- /// Rename the default libcall routine name for the specified libcall.
- void setLibcallImpl(RTLIB::Libcall Call, RTLIB::LibcallImpl Impl) {
- LibcallImpls[Call] = Impl;
- }
-
- /// Get the libcall routine name for the specified libcall.
- // FIXME: This should be removed. Only LibcallImpl should have a name.
- StringRef getLibcallName(RTLIB::Libcall Call) const {
- return getLibcallImplName(LibcallImpls[Call]);
- }
-
/// Get the libcall routine name for the specified libcall implementation.
static StringRef getLibcallImplName(RTLIB::LibcallImpl CallImpl) {
if (CallImpl == RTLIB::Unsupported)
@@ -105,31 +98,20 @@ struct RuntimeLibcallsInfo {
RuntimeLibcallNameSizeTable[CallImpl]);
}
- /// Return the lowering's selection of implementation call for \p Call
- RTLIB::LibcallImpl getLibcallImpl(RTLIB::Libcall Call) const {
- return LibcallImpls[Call];
- }
-
/// Set the CallingConv that should be used for the specified libcall
/// implementation
void setLibcallImplCallingConv(RTLIB::LibcallImpl Call, CallingConv::ID CC) {
LibcallImplCallingConvs[Call] = CC;
}
- // FIXME: Remove this wrapper in favor of directly using
- // getLibcallImplCallingConv
- CallingConv::ID getLibcallCallingConv(RTLIB::Libcall Call) const {
- return LibcallImplCallingConvs[LibcallImpls[Call]];
- }
-
/// Get the CallingConv that should be used for the specified libcall.
CallingConv::ID getLibcallImplCallingConv(RTLIB::LibcallImpl Call) const {
return LibcallImplCallingConvs[Call];
}
- ArrayRef<RTLIB::LibcallImpl> getLibcallImpls() const {
- // Trim UNKNOWN_LIBCALL from the back
- return ArrayRef(LibcallImpls).drop_back();
+ /// Return the libcall provided by \p Impl
+ static RTLIB::Libcall getLibcallFromImpl(RTLIB::LibcallImpl Impl) {
+ return ImplToLibcall[Impl];
}
/// Return a function name compatible with RTLIB::MEMCPY, or nullptr if fully
@@ -143,6 +125,10 @@ struct RuntimeLibcallsInfo {
return getLibcallImpl(RTLIB::MEMMOVE);
}
+ unsigned getNumAvailableLibcallImpls() const {
+ return AvailableLibcallImpls.count();
+ }
+
bool isAvailable(RTLIB::LibcallImpl Impl) const {
return AvailableLibcallImpls.test(Impl);
}
@@ -151,11 +137,6 @@ struct RuntimeLibcallsInfo {
AvailableLibcallImpls.set(Impl);
}
- /// Return the libcall provided by \p Impl
- static RTLIB::Libcall getLibcallFromImpl(RTLIB::LibcallImpl Impl) {
- return ImplToLibcall[Impl];
- }
-
/// Check if a function name is a recognized runtime call of any kind. This
/// does not consider if this call is available for any current compilation,
/// just that it is a known call somewhere. This returns the set of all
@@ -176,11 +157,8 @@ struct RuntimeLibcallsInfo {
LLVM_ABI RTLIB::LibcallImpl
getSupportedLibcallImpl(StringRef FuncName) const {
for (RTLIB::LibcallImpl Impl : lookupLibcallImplName(FuncName)) {
- // FIXME: This should not depend on looking up ImplToLibcall, only the
- // list of libcalls for the module.
- RTLIB::LibcallImpl Recognized = LibcallImpls[ImplToLibcall[Impl]];
- if (Recognized != RTLIB::Unsupported)
- return Recognized;
+ if (isAvailable(Impl))
+ return Impl;
}
return RTLIB::Unsupported;
@@ -197,10 +175,6 @@ struct RuntimeLibcallsInfo {
LLVM_ABI static iota_range<RTLIB::LibcallImpl>
lookupLibcallImplNameImpl(StringRef Name);
- /// Stores the implementation choice for each each libcall.
- RTLIB::LibcallImpl LibcallImpls[RTLIB::UNKNOWN_LIBCALL + 1] = {
- RTLIB::Unsupported};
-
static_assert(static_cast<int>(CallingConv::C) == 0,
"default calling conv should be encoded as 0");
diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp
index b3535eaca5e9d..bd6f447434cbd 100644
--- a/llvm/lib/CodeGen/TargetLoweringBase.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp
@@ -695,11 +695,28 @@ ISD::CondCode TargetLoweringBase::getSoftFloatCmpLibcallPredicate(
}
}
+LibcallLoweringInfo::LibcallLoweringInfo(
+ const RTLIB::RuntimeLibcallsInfo &RTLCI)
+ : RTLCI(RTLCI) {
+ // TODO: This should be generated with lowering predicates, and assert the
+ // call is available.
+ for (RTLIB::LibcallImpl Impl : RTLIB::libcall_impls()) {
+ if (RTLCI.isAvailable(Impl)) {
+ RTLIB::Libcall LC = RTLIB::RuntimeLibcallsInfo::getLibcallFromImpl(Impl);
+ // FIXME: Hack, assume the first available libcall wins.
+ if (LibcallImpls[LC] == RTLIB::Unsupported)
+ LibcallImpls[LC] = Impl;
+ }
+ }
+}
+
/// NOTE: The TargetMachine owns TLOF.
TargetLoweringBase::TargetLoweringBase(const TargetMachine &tm)
- : TM(tm), Libcalls(TM.getTargetTriple(), TM.Options.ExceptionModel,
- TM.Options.FloatABIType, TM.Options.EABIVersion,
- TM.Options.MCOptions.getABIName()) {
+ : TM(tm),
+ RuntimeLibcallInfo(TM.getTargetTriple(), TM.Options.ExceptionModel,
+ TM.Options.FloatABIType, TM.Options.EABIVersion,
+ TM.Options.MCOptions.getABIName()),
+ Libcalls(RuntimeLibcallInfo) {
initActions();
// Perform these initializations only once.
diff --git a/llvm/lib/IR/RuntimeLibcalls.cpp b/llvm/lib/IR/RuntimeLibcalls.cpp
index 2ce5719228a0d..2fb01a4f95fea 100644
--- a/llvm/lib/IR/RuntimeLibcalls.cpp
+++ b/llvm/lib/IR/RuntimeLibcalls.cpp
@@ -19,6 +19,7 @@
using namespace llvm;
using namespace RTLIB;
+#define GET_RUNTIME_LIBCALLS_INFO
#define GET_INIT_RUNTIME_LIBCALL_NAMES
#define GET_SET_TARGET_RUNTIME_LIBCALL_SETS
#define DEFINE_GET_LOOKUP_LIBCALL_IMPL_NAME
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp
index 23be42f9d60ce..fefc733fa7697 100644
--- a/llvm/lib/LTO/LTO.cpp
+++ b/llvm/lib/LTO/LTO.cpp
@@ -1396,11 +1396,10 @@ Error LTO::runRegularLTO(AddStreamFn AddStream) {
SmallVector<const char *> LTO::getRuntimeLibcallSymbols(const Triple &TT) {
RTLIB::RuntimeLibcallsInfo Libcalls(TT);
SmallVector<const char *> LibcallSymbols;
- ArrayRef<RTLIB::LibcallImpl> LibcallImpls = Libcalls.getLibcallImpls();
- LibcallSymbols.reserve(LibcallImpls.size());
+ LibcallSymbols.reserve(Libcalls.getNumAvailableLibcallImpls());
- for (RTLIB::LibcallImpl Impl : LibcallImpls) {
- if (Impl != RTLIB::Unsupported)
+ for (RTLIB::LibcallImpl Impl : RTLIB::libcall_impls()) {
+ if (Libcalls.isAvailable(Impl))
LibcallSymbols.push_back(Libcalls.getLibcallImplName(Impl).data());
}
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
index 45b0e7dc12263..f3c236ca8c9ce 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyRuntimeLibcallSignatures.cpp
@@ -532,13 +532,19 @@ struct StaticLibcallNameMap {
// FIXME: This is broken if there are ever different triples compiled with
// different libcalls.
RTLIB::RuntimeLibcallsInfo RTCI(TT);
- for (RTLIB::Libcall LC : RTLIB::libcalls()) {
- StringRef NameLibcall = RTCI.getLibcallName(LC);
- if (!NameLibcall.empty() &&
- getRuntimeLibcallSignatures().Table[LC] != unsupported) {
- assert(!Map.contains(NameLibcall) &&
- "duplicate libcall names in name map");
- Map[NameLibcall] = LC;
+
+ ArrayRef<RuntimeLibcallSignature> Table =
+ getRuntimeLibcallSignatures().Table;
+ for (RTLIB::LibcallImpl Impl : RTLIB::libcall_impls()) {
+ if (!RTCI.isAvailable(Impl))
+ continue;
+ RTLIB::Libcall LC = RTLIB::RuntimeLibcallsInfo::getLibcallFromImpl(Impl);
+ if (Table[LC] != unsupported) {
+ StringRef NameLibcall =
+ RTLIB::RuntimeLibcallsInfo::getLibcallImplName(Impl);
+ // FIXME: Map should be to LibcallImpl
+ if (!Map.insert({NameLibcall, LC}).second)
+ llvm_unreachable("duplicate libcall names in name map");
}
}
}
diff --git a/llvm/lib/Transforms/Utils/DeclareRuntimeLibcalls.cpp b/llvm/lib/Transforms/Utils/DeclareRuntimeLibcalls.cpp
index 6d4436b92c119..dd8706cfb2855 100644
--- a/llvm/lib/Transforms/Utils/DeclareRuntimeLibcalls.cpp
+++ b/llvm/lib/Transforms/Utils/DeclareRuntimeLibcalls.cpp
@@ -54,8 +54,8 @@ PreservedAnalyses DeclareRuntimeLibcallsPass::run(Module &M,
const DataLayout &DL = M.getDataLayout();
const Triple &TT = M.getTargetTriple();
- for (RTLIB::LibcallImpl Impl : RTLCI.getLibcallImpls()) {
- if (Impl == RTLIB::Unsupported)
+ for (RTLIB::LibcallImpl Impl : RTLIB::libcall_impls()) {
+ if (!RTLCI.isAvailable(Impl))
continue;
auto [FuncTy, FuncAttrs] = RTLCI.getFunctionTy(Ctx, TT, DL, Impl);
diff --git a/llvm/test/TableGen/RuntimeLibcallEmitter-calling-conv.td b/llvm/test/TableGen/RuntimeLibcallEmitter-calling-conv.td
index 2904474f6110b..e4a7126d79fbd 100644
--- a/llvm/test/TableGen/RuntimeLibcallEmitter-calling-conv.td
+++ b/llvm/test/TableGen/RuntimeLibcallEmitter-calling-conv.td
@@ -53,21 +53,21 @@ def MSP430LibraryWithCondCC : SystemRuntimeLibrary<isMSP430,
// CHECK-NEXT: });
// CHECK-NEXT: AvailableLibcallImpls = SystemAvailableImpls;
// CHECK-EMPTY:
-// CHECK-NEXT: static const LibcallImplPair LibraryCalls[] = {
-// CHECK-NEXT: {RTLIB::MALLOC, RTLIB::impl_malloc}, // malloc
+// CHECK-NEXT: static const RTLIB::LibcallImpl LibraryCalls[] = {
+// CHECK-NEXT: RTLIB::impl_malloc, // malloc
// CHECK-NEXT: };
// CHECK-EMPTY:
-// CHECK-NEXT: for (const auto [Func, Impl] : LibraryCalls) {
-// CHECK-NEXT: setLibcallImpl(Func, Impl);
+// CHECK-NEXT: for (const RTLIB::LibcallImpl Impl : LibraryCalls) {
+// CHECK-NEXT: setAvailable(Impl);
// CHECK-NEXT: }
// CHECK-EMPTY:
-// CHECK-NEXT: static const LibcallImplPair LibraryCalls_AlwaysAvailable_AVR_BUILTIN[] = {
-// CHECK-NEXT: {RTLIB::SDIVREM_I8, RTLIB::impl___divmodqi4}, // __divmodqi4
-// CHECK-NEXT: {RTLIB::UDIVREM_I16, RTLIB::impl___udivmodhi4}, // __udivmodhi4
+// CHECK-NEXT: static const RTLIB::LibcallImpl LibraryCalls_AlwaysAvailable_AVR_BUILTIN[] = {
+// CHECK-NEXT: RTLIB::impl___divmodqi4, // __divmodqi4
+// CHECK-NEXT: RTLIB::impl___udivmodhi4, // __udivmodhi4
// CHECK-NEXT: };
// CHECK-EMPTY:
-// CHECK-NEXT: for (const auto [Func, Impl] : LibraryCalls_AlwaysAvailable_AVR_BUILTIN) {
-// CHECK-NEXT: setLibcallImpl(Func, Impl);
+// CHECK-NEXT: for (const RTLIB::LibcallImpl Impl : LibraryCalls_AlwaysAvailable_AVR_BUILTIN) {
+// CHECK-NEXT: setAvailable(Impl);
// CHECK-NEXT: setLibcallImplCallingConv(Impl, CallingConv::AVR_BUILTIN);
// CHECK-NEXT: }
// CHECK-EMPTY:
@@ -80,21 +80,21 @@ def MSP430LibraryWithCondCC : SystemRuntimeLibrary<isMSP430,
// CHECK-NEXT: });
// CHECK-NEXT: AvailableLibcallImpls = SystemAvailableImpls;
// CHECK-EMPTY:
-// CHECK-NEXT: static const LibcallImplPair LibraryCalls[] = {
-// CHECK-NEXT: {RTLIB::MALLOC, RTLIB::impl_malloc}, // malloc
+// CHECK-NEXT: static const RTLIB::LibcallImpl LibraryCalls[] = {
+// CHECK-NEXT: RTLIB::impl_malloc, // malloc
// CHECK-NEXT: };
// CHECK-EMPTY:
-// CHECK-NEXT: for (const auto [Func, Impl] : LibraryCalls) {
-// CHECK-NEXT: setLibcallImpl(Func, Impl);
+// CHECK-NEXT: for (const RTLIB::LibcallImpl Impl : LibraryCalls) {
+// CHECK-NEXT: setAvailable(Impl);
// CHECK-NEXT: }
// CHECK-EMPTY:
-// CHECK-NEXT: static const LibcallImplPair LibraryCalls_AlwaysAvailable_AVR_BUILTIN[] = {
-// CHECK-NEXT: {RTLIB::SDIVREM_I8, RTLIB::impl___divmodqi4}, // __divmodqi4
-// CHECK-NEXT: {RTLIB::UDIVREM_I16, RTLIB::impl___udivmodhi4}, // __udivmodhi4
+// CHECK-NEXT: static const RTLIB::LibcallImpl LibraryCalls_AlwaysAvailable_AVR_BUILTIN[] = {
+// CHECK-NEXT: RTLIB::impl___divmodqi4, // __divmodqi4
+// CHECK-NEXT: RTLIB::impl___udivmodhi4, // __udivmodhi4
// CHECK-NEXT: };
// CHECK-EMPTY:
-// CHECK-NEXT: for (const auto [Func, Impl] : LibraryCalls_AlwaysAvailable_AVR_BUILTIN) {
-// CHECK-NEXT: setLibcallImpl(Func, Impl);
+// CHECK-NEXT: for (const RTLIB::LibcallImpl Impl : LibraryCalls_AlwaysAvailable_AVR_BUILTIN) {
+// CHECK-NEXT: setAvailable(Impl);
// CHECK-NEXT: setLibcallImplCallingConv(Impl, CallingConv::AVR_BUILTIN);
// CHECK-NEXT: }
// CHECK-EMPTY:
@@ -107,33 +107,33 @@ def MSP430LibraryWithCondCC : SystemRuntimeLibrary<isMSP430,
// CHECK-NEXT: });
// CHECK-NEXT: AvailableLibcallImpls = SystemAvailableImpls;
// CHECK-EMPTY:
-// CHECK-NEXT: static const LibcallImplPair LibraryCalls[] = {
-// CHECK-NEXT: {RTLIB::MALLOC, RTLIB::impl_malloc}, // malloc
+// CHECK-NEXT: static const RTLIB::LibcallImpl LibraryCalls[] = {
+// CHECK-NEXT: RTLIB::impl_malloc, // malloc
// CHECK-NEXT: };
// CHECK-EMPTY:
-// CHECK-NEXT: for (const auto [Func, Impl] : LibraryCalls) {
-// CHECK-NEXT: setLibcallImpl(Func, Impl);
+// CHECK-NEXT: for (const RTLIB::LibcallImpl Impl : LibraryCalls) {
+// CHECK-NEXT: setAvailable(Impl);
// CHECK-NEXT: }
// CHECK-EMPTY:
// CHECK-NEXT: if ( isFoo() ) {
-// CHECK-NEXT: static const LibcallImplPair LibraryCalls_anonymous_3_AVR_BUILTIN[] = {
-// CHECK-NEXT: {RTLIB::SDIVREM_I8, RTLIB::impl___divmodqi4}, // __divmodqi4
+// CHECK-NEXT: static const RTLIB::LibcallImpl LibraryCalls_anonymous_3_AVR_BUILTIN[] = {
+// CHECK-NEXT: RTLIB::impl___divmodqi4, // __divmodqi4
// CHECK-NEXT: };
// CHECK-EMPTY:
-// CHECK-NEXT: for (const auto [Func, Impl] : LibraryCalls_anonymous_3_AVR_BUILTIN) {
-// CHECK-NEXT: setLibcallImpl(Func, Impl);
+// CHECK-NEXT: for (const RTLIB::LibcallImpl Impl : LibraryCalls_anonymous_3_AVR_BUILTIN) {
+// CHECK-NEXT: setAvailable(Impl);
// CHECK-NEXT: setLibcallImplCallingConv(Impl, CallingConv::AVR_BUILTIN);
// CHECK-NEXT: }
// CHECK-EMPTY:
// CHECK-NEXT: }
// CHECK-EMPTY:
// CHECK-NEXT: if ( isBar() ) {
-// CHECK-NEXT: static const LibcallImplPair LibraryCalls_anonymous_5_MSP430_BUILTIN[] = {
-// CHECK-NEXT: {RTLIB::UDIVREM_I16, RTLIB::impl___udivmodhi4}, // __udivmodhi4
+// CHECK-NEXT: static const RTLIB::LibcallImpl LibraryCalls_anonymous_5_MSP430_BUILTIN[] = {
+// CHECK-NEXT: RTLIB::impl___udivmodhi4, // __udivmodhi4
// CHECK-NEXT: };
// CHECK-EMPTY:
-// CHECK-NEXT: for (const auto [Func, Impl] : LibraryCalls_anonymous_5_MSP430_BUILTIN) {
-// CHECK-NEXT: setLibcallImpl(Func, Impl);
+// CHECK-NEXT: for (const RTLIB::LibcallImpl Impl : LibraryCalls_anonymous_5_MSP430_BUILTIN) {
+// CHECK-NEXT: setAvailable(Impl);
// CHECK-NEXT: setLibcallImplCallingConv(Impl, CallingConv::MSP430_BUILTIN);
// CHECK-NEXT: }
// CHECK-EMPTY:
diff --git a/llvm/test/TableGen/RuntimeLibcallEmitter-conflict-warning.td b/llvm/test/TableGen/RuntimeLibcallEmitter-conflict-warning.td
index f9a148a183806..82206ce6ba254 100644
--- a/llvm/test/TableGen/RuntimeLibcallEmitter-conflict-warning.td
+++ b/llvm/test/TableGen/RuntimeLibcallEmitter-conflict-warning.td
@@ -31,12 +31,12 @@ def dup1 : RuntimeLibcallImpl<ANOTHER_DUP>;
// CHECK-NEXT: AvailableLibcallImpls = SystemAvailableImpls;
// CHECK-EMPTY:
-// CHECK-NEXT: static const LibcallImplPair LibraryCalls[] = {
-// CHECK-NEXT: {RTLIB::SOME_FUNC, RTLIB::impl_func_b}, // func_b
+// CHECK-NEXT: static const RTLIB::LibcallImpl LibraryCalls[] = {
+// CHECK-NEXT: RTLIB::impl_func_b, // func_b
// CHECK-NEXT: };
// CHECK-EMPTY:
-// CHECK-NEXT: for (const auto [Func, Impl] : LibraryCalls) {
-// CHECK-NEXT: setLibcallImpl(Func, Impl);
+// CHECK-NEXT: for (const RTLIB::LibcallImpl Impl : LibraryCalls) {
+// CHECK-NEXT: setAvailable(Impl);
// CHECK-NEXT: }
// CHECK-EMPTY:
// CHECK-NEXT: return;
@@ -53,13 +53,13 @@ def TheSystemLibraryA : SystemRuntimeLibrary<isTargetArchA,
// CHECK-NEXT: });
// CHECK-NEXT: AvailableLibcallImpls = SystemAvailableImpls;
// CHECK-EMPTY:
-// CHECK-NEXT: static const LibcallImplPair LibraryCalls[] = {
-// CHECK-NEXT: {RTLIB::OTHER_FUNC, RTLIB::impl_other_func}, // other_func
-// CHECK-NEXT: {RTLIB::SOME_FUNC, RTLIB::impl_func_a}, // func_a
+// CHECK-NEXT: static const RTLIB::LibcallImpl LibraryCalls[] = {
+// CHECK-NEXT: RTLIB::impl_other_func, // other_func
+// CHECK-NEXT: RTLIB::impl_func_a, // func_a
// CHECK-NEXT: };
// CHECK-EMPTY:
-// CHECK-NEXT: for (const auto [Func, Impl] : LibraryCalls) {
-// CHECK-NEXT: setLibcallImpl(Func, Impl);
+// CHECK-NEXT: for (const RTLIB::LibcallImpl Impl : LibraryCalls) {
+// CHECK-NEXT: setAvailable(Impl);
// CHECK-NEXT: }
// CHECK-EMPTY:
// CHECK-NEXT: return;
@@ -76,14 +76,14 @@ def TheSystemLibraryB : SystemRuntimeLibrary<isTargetArchB,
// CHECK-NEXT: });
// CHECK-NEXT: AvailableLibcallImpls = SystemAvailableImpls;
// CHECK-EMPTY:
-// CHECK-NEXT: static const LibcallImplPair LibraryCalls[] = {
-// CHECK-NEXT: {RTLIB::ANOTHER_DUP, RTLIB::impl_dup1}, // dup1
-// CHECK-NEXT: {RTLIB::OTHER_FUNC, RTLIB::impl_other_func}, // other_func
-// CHECK-NEXT: {RTLIB::SOME_FUNC, RTLIB::impl_func_a}, // func_a
+// CHECK-NEXT: static const RTLIB::LibcallImpl LibraryCalls[] = {
+// CHECK-NEXT: RTLIB::impl_dup1, // dup1
+// CHECK-NEXT: RTLIB::impl_other_func, // other_func
+// CHECK-NEXT: RTLIB::impl_func_a, // func_a
// CHECK-NEXT: };
// CHECK-EMPTY:
-// CHECK-NEXT: for (const auto [Func, Impl] : LibraryCalls) {
-// CHECK-NEXT: setLibcallImpl(Func, Impl);
+// CHECK-NEXT: for (const RTLIB::LibcallImpl Impl : LibraryCalls) {
+// CHECK-NEXT: setAvailable(Impl);
// CHECK-NEXT: }
// CHECK-EMPTY:
// CHECK-NEXT: return;
diff --git a/llvm/test/TableGen/RuntimeLibcallEmitter.td b/llvm/test/TableGen/RuntimeLibcallEmitter.td
index 7aaf3a0e8e1cf..2a1cc72efcd4b 100644
--- a/llvm/test/TableGen/RuntimeLibcallEmitter.td
+++ b/llvm/test/TableGen/RuntimeLibcallEmitter.td
@@ -200,10 +200,6 @@ def BlahLibrary : SystemRuntimeLibrary<isBlahArch, (add calloc, LibraryWithCondi
// CHECK-NEXT: }
// CHECK: void llvm::RTLIB::RuntimeLibcallsInfo::setTargetRuntimeLibcallSets(const llvm::Triple &TT, ExceptionHandling ExceptionModel, FloatABI::ABIType FloatABI, EABI EABIVersion, StringRef ABIName) {
-// CHECK-NEXT: struct LibcallImplPair {
-// CHECK-NEXT: RTLIB::Libcall Func;
-// CHECK-NEXT: RTLIB::LibcallImpl Impl;
-// CHECK-NEXT: };
// CHECK-EMPTY:
// CHECK-NEXT: if (TT.getArch() == Triple::blah) {
// CHECK-NEXT: static constexpr LibcallImplBitset SystemAvailableImpls({
@@ -211,35 +207,35 @@ def BlahLibrary : SystemRuntimeLibrary<isBlahArch, (add calloc, LibraryWithCondi
// CHECK-NEXT: });
// CHECK-NEXT: AvailableLibcallImpls = SystemAvailableImpls;
// CHECK-EMPTY:
-// CHECK-NEXT: static const LibcallImplPair LibraryCalls[] = {
-// CHECK-NEXT: {RTLIB::BZERO, RTLIB::impl_bzero}, // bzero
-// CHECK-NEXT: {RTLIB::CALLOC, RTLIB::impl_calloc}, // calloc
-// CHECK-NEXT: {RTLIB::SQRT_F128, RTLIB::impl_sqrtl_f128}, // sqrtl
+// CHECK-NEXT: static const RTLIB::LibcallImpl LibraryCalls[] = {
+// CHECK-NEXT: RTLIB::impl_bzero, // bzero
+// CHECK-NEXT: RTLIB::impl_calloc, // calloc
+// CHECK-NEXT: RTLIB::impl_sqrtl_f128, // sqrtl
// CHECK-NEXT: };
// CHECK-EMPTY:
-// CHECK-NEXT: for (const auto [Func, Impl] : LibraryCalls) {
-// CHECK-NEXT: setLibcallImpl(Func, Impl);
+// CHECK-NEXT: for (const RTLIB::LibcallImpl Impl : LibraryCalls) {
+// CHECK-NEXT: setAvailable(Impl);
// CHECK-NEXT: }
// CHECK-EMPTY:
// CHECK-NEXT: if (TT.hasCompilerRT()) {
-// CHECK-NEXT: static const LibcallImplPair LibraryCalls_hasCompilerRT[] = {
-// CHECK-NEXT: {RTLIB::SHL_I32, RTLIB::impl___ashlsi3}, // __ashlsi3
-// CHECK-NEXT: {RTLIB::SRL_I64, RTLIB::impl___lshrdi3}, // __lshrdi3
+// CHECK-NEXT: static const RTLIB::LibcallImpl LibraryCalls_hasCompilerRT[] = {
+// CHECK-NEXT: RTLIB::impl___ashlsi3, // __ashlsi3
+// CHECK-NEXT: RTLIB::impl___lshrdi3, // __lshrdi3
// CHECK-NEXT: };
// CHECK-EMPTY:
-// CHECK-NEXT: for (const auto [Func, Impl] : LibraryCalls_hasCompilerRT) {
-// CHECK-NEXT: setLibcallImpl(Func, Impl);
+// CHECK-NEXT: for (const RTLIB::LibcallImpl Impl : LibraryCalls_hasCompilerRT) {
+// CHECK-NEXT: setAvailable(Impl);
// CHECK-NEXT: }
// CHECK-EMPTY:
// CHECK-NEXT: }
// CHECK-EMPTY:
// CHECK-NEXT: if (TT.getOS() == Triple::bar) {
-// CHECK-NEXT: static const LibcallImplPair LibraryCalls_isBarOS[] = {
-// CHECK-NEXT: {RTLIB::MEMSET, RTLIB::impl____memset}, // ___memset
+// CHECK-NEXT: static const RTLIB::LibcallImpl LibraryCalls_isBarOS[] = {
+// CHECK-NEXT: RTLIB::impl____memset, // ___memset
// CHECK-NEXT: };
// CHECK-EMPTY:
-// CHECK-NEXT: for (const auto [Func, Impl] : LibraryCalls_isBarOS) {
-// CHECK-NEXT: setLibcallImpl(Func, Impl);
+// CHECK-NEXT: for (const RTLIB::LibcallImpl Impl : LibraryCalls_isBarOS) {
+// CHECK-NEXT: setAvailable(Impl);
// CHECK-NEXT: }
// CHECK-EMPTY:
// CHECK-NEXT: }
@@ -253,14 +249,14 @@ def BlahLibrary : SystemRuntimeLibrary<isBlahArch, (add calloc, LibraryWithCondi
// CHECK-NEXT: });
// CHECK-NEXT: AvailableLibcallImpls = SystemAvailableImpls;
// CHECK-EMPTY:
-// CHECK-NEXT: static const LibcallImplPair LibraryCalls[] = {
-// CHECK-NEXT: {RTLIB::SHL_I32, RTLIB::impl___ashlsi3}, // __ashlsi3
-// CHECK-NEXT: {RTLIB::SQRT_F80, RTLIB::impl_sqrtl_f80}, // sqrtl
-// CHECK-NEXT: {RTLIB::SRL_I64, RTLIB::impl___lshrdi3}, // __lshrdi3
+// CHECK-NEXT: static const RTLIB::LibcallImpl LibraryCalls[] = {
+// CHECK-NEXT: RTLIB::impl___ashlsi3, // __ashlsi3
+// CHECK-NEXT: RTLIB::impl_sqrtl_f80, // sqrtl
+// CHECK-NEXT: RTLIB::impl___lshrdi3, // __lshrdi3
// CHECK-NEXT: };
// CHECK-EMPTY:
-// CHECK-NEXT: for (const auto [Func, Impl] : LibraryCalls) {
-// CHECK-NEXT: setLibcallImpl(Func, Impl);
+// CHECK-NEXT: for (const RTLIB::LibcallImpl Impl : LibraryCalls) {
+// CHECK-NEXT: setAvailable(Impl);
// CHECK-NEXT: }
// CHECK-EMPTY:
// CHECK-NEXT: return;
@@ -272,22 +268,22 @@ def BlahLibrary : SystemRuntimeLibrary<isBlahArch, (add calloc, LibraryWithCondi
// CHECK-NEXT: });
// CHECK-NEXT: AvailableLibcallImpls = SystemAvailableImpls;
// CHECK-EMPTY:
-// CHECK-NEXT: static const LibcallImplPair LibraryCalls[] = {
-// CHECK-NEXT: {RTLIB::BZERO, RTLIB::impl_bzero}, // bzero
-// CHECK-NEXT: {RTLIB::SQRT_F128, RTLIB::impl_sqrtl_f128}, // sqrtl
+// CHECK-NEXT: static const RTLIB::LibcallImpl LibraryCalls[] = {
+// CHECK-NEXT: RTLIB::impl_bzero, // bzero
+// CHECK-NEXT: RTLIB::impl_sqrtl_f128, // sqrtl
// CHECK-NEXT: };
// CHECK-EMPTY:
-// CHECK-NEXT: for (const auto [Func, Impl] : LibraryCalls) {
-// CHECK-NEXT: setLibcallImpl(Func, Impl);
+// CHECK-NEXT: for (const RTLIB::LibcallImpl Impl : LibraryCalls) {
+// CHECK-NEXT: setAvailable(Impl);
// CHECK-NEXT: }
// CHECK-EMPTY:
// CHECK-NEXT: if (TT.getOS() == Triple::bar) {
-// CHECK-NEXT: static const LibcallImplPair LibraryCalls_isBarOS[] = {
-// CHECK-NEXT: {RTLIB::MEMSET, RTLIB::impl____memset}, // ___memset
+// CHECK-NEXT: static const RTLIB::LibcallImpl LibraryCalls_isBarOS[] = {
+// CHECK-NEXT: RTLIB::impl____memset, // ___memset
// CHECK-NEXT: };
// CHECK-EMPTY:
-// CHECK-NEXT: for (const auto [Func, Impl] : LibraryCalls_isBarOS) {
-// CHECK-NEXT: setLibcallImpl(Func, Impl);
+// CHECK-NEXT: for (const RTLIB::LibcallImpl Impl : LibraryCalls_isBarOS) {
+// CHECK-NEXT: setAvailable(Impl);
// CHECK-NEXT: }
// CHECK-EMPTY:
// CHECK-NEXT: }
@@ -301,15 +297,15 @@ def BlahLibrary : SystemRuntimeLibrary<isBlahArch, (add calloc, LibraryWithCondi
// CHECK-NEXT: });
// CHECK-NEXT: AvailableLibcallImpls = SystemAvailableImpls;
// CHECK-EMPTY:
-// CHECK-NEXT: static const LibcallImplPair LibraryCalls[] = {
-// CHECK-NEXT: {RTLIB::CALLOC, RTLIB::impl_calloc}, // calloc
-// CHECK-NEXT: {RTLIB::SHL_I32, RTLIB::impl___ashlsi3}, // __ashlsi3
-// CHECK-NEXT: {RTLIB::SQRT_F80, RTLIB::impl_sqrtl_f80}, // sqrtl
-// CHECK-NEXT: {RTLIB::SRL_I64, RTLIB::impl___lshrdi3}, // __lshrdi3
+// CHECK-NEXT: static const RTLIB::LibcallImpl LibraryCalls[] = {
+// CHECK-NEXT: RTLIB::impl_calloc, // calloc
+// CHECK-NEXT: RTLIB::impl___ashlsi3, // __ashlsi3
+// CHECK-NEXT: RTLIB::impl_sqrtl_f80, // sqrtl
+// CHECK-NEXT: RTLIB::impl___lshrdi3, // __lshrdi3
// CHECK-NEXT: };
// CHECK-EMPTY:
-// CHECK-NEXT: for (const auto [Func, Impl] : LibraryCalls) {
-// CHECK-NEXT: setLibcallImpl(Func, Impl);
+// CHECK-NEXT: for (const RTLIB::LibcallImpl Impl : LibraryCalls) {
+// CHECK-NEXT: setAvailable(Impl);
// CHECK-NEXT: }
// CHECK-EMPTY:
// CHECK-NEXT: return;
diff --git a/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/basic.ll b/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/basic.ll
index c005316f07f06..4c8c829a59f3c 100644
--- a/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/basic.ll
+++ b/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/basic.ll
@@ -10,10 +10,15 @@ define float @sinf(float %x) {
ret float %x
}
+; CHECK: declare void @_Unwind_Resume(...)
+
+; CHECK: declare void @__umodti3(...)
+
; CHECK: declare void @acosf(...)
-; CHECK: declare nofpclass(ninf nsub nnorm) float @sqrtf(float) [[SQRT_ATTRS:#[0-9]+]]
; CHECK: declare nofpclass(ninf nsub nnorm) double @sqrt(double) [[SQRT_ATTRS:#[0-9]+]]
-; CHECK: declare void @__umodti3(...)
+; CHECK: declare nofpclass(ninf nsub nnorm) float @sqrtf(float) [[SQRT_ATTRS:#[0-9]+]]
+
+; CHECK: declare void @truncl(...)
diff --git a/llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp b/llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp
index 6a36f471678bf..001ca7b658d3c 100644
--- a/llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp
+++ b/llvm/utils/TableGen/Basic/RuntimeLibcallsEmitter.cpp
@@ -544,11 +544,8 @@ void RuntimeLibcallEmitter::emitSystemRuntimeLibrarySetCalls(
OS << "void llvm::RTLIB::RuntimeLibcallsInfo::setTargetRuntimeLibcallSets("
"const llvm::Triple &TT, ExceptionHandling ExceptionModel, "
"FloatABI::ABIType FloatABI, EABI EABIVersion, "
- "StringRef ABIName) {\n"
- " struct LibcallImplPair {\n"
- " RTLIB::Libcall Func;\n"
- " RTLIB::LibcallImpl Impl;\n"
- " };\n";
+ "StringRef ABIName) {\n";
+
ArrayRef<const Record *> AllLibs =
Records.getAllDerivedDefinitions("SystemRuntimeLibrary");
@@ -703,7 +700,7 @@ void RuntimeLibcallEmitter::emitSystemRuntimeLibrarySetCalls(
Funcs.erase(UniqueI, Funcs.end());
OS << indent(IndentDepth + 2)
- << "static const LibcallImplPair LibraryCalls";
+ << "static const RTLIB::LibcallImpl LibraryCalls";
SubsetPredicate.emitTableVariableNameSuffix(OS);
if (FuncsWithCC.CallingConv)
OS << '_' << FuncsWithCC.CallingConv->getName();
@@ -711,18 +708,18 @@ void RuntimeLibcallEmitter::emitSystemRuntimeLibrarySetCalls(
OS << "[] = {\n";
for (const RuntimeLibcallImpl *LibCallImpl : Funcs) {
OS << indent(IndentDepth + 6);
- LibCallImpl->emitTableEntry(OS);
+ LibCallImpl->emitEnumEntry(OS);
+ OS << ", // " << LibCallImpl->getLibcallFuncName() << '\n';
}
OS << indent(IndentDepth + 2) << "};\n\n"
<< indent(IndentDepth + 2)
- << "for (const auto [Func, Impl] : LibraryCalls";
+ << "for (const RTLIB::LibcallImpl Impl : LibraryCalls";
SubsetPredicate.emitTableVariableNameSuffix(OS);
if (FuncsWithCC.CallingConv)
OS << '_' << FuncsWithCC.CallingConv->getName();
- OS << ") {\n"
- << indent(IndentDepth + 4) << "setLibcallImpl(Func, Impl);\n";
+ OS << ") {\n" << indent(IndentDepth + 4) << "setAvailable(Impl);\n";
if (FuncsWithCC.CallingConv) {
StringRef CCEnum =
@@ -759,7 +756,7 @@ void RuntimeLibcallEmitter::run(raw_ostream &OS) {
emitGetInitRuntimeLibcallNames(OS);
{
- IfDefEmitter IfDef(OS, "GET_SET_TARGET_RUNTIME_LIBCALL_SETS");
+ IfDefEmitter IfDef(OS, "GET_RUNTIME_LIBCALLS_INFO");
emitSystemRuntimeLibrarySetCalls(OS);
}
}
>From 90f39172bec45b4f9ccdec850c06fcc5b8e0a6c3 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Sat, 25 Oct 2025 22:09:08 +0900
Subject: [PATCH 2/6] CodeGen: Move LibcallLoweringInfo to be with
RuntimeLibcallInfo
Eventually this will be program dependent state, so it should not
be part of TargetLowering. It's easiest to have this as part of
the analysis that will provide RuntimeLibcallInfo. In principle
we would also need this to more precisely refine the set of libcalls
that full LTO could trim based on the subtarget.
---
llvm/include/llvm/CodeGen/TargetLowering.h | 52 --------------------
llvm/include/llvm/IR/RuntimeLibcalls.h | 57 +++++++++++++++++++++-
llvm/lib/CodeGen/TargetLoweringBase.cpp | 15 ------
llvm/lib/IR/RuntimeLibcalls.cpp | 15 ++++++
4 files changed, 70 insertions(+), 69 deletions(-)
diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h b/llvm/include/llvm/CodeGen/TargetLowering.h
index d8ec8441dd565..636d4f979ec65 100644
--- a/llvm/include/llvm/CodeGen/TargetLowering.h
+++ b/llvm/include/llvm/CodeGen/TargetLowering.h
@@ -193,58 +193,6 @@ struct MemOp {
}
};
-class LibcallLoweringInfo {
-private:
- LLVM_ABI const RTLIB::RuntimeLibcallsInfo &RTLCI;
- /// Stores the implementation choice for each each libcall.
- LLVM_ABI RTLIB::LibcallImpl LibcallImpls[RTLIB::UNKNOWN_LIBCALL + 1] = {
- RTLIB::Unsupported};
-
-public:
- LLVM_ABI LibcallLoweringInfo(const RTLIB::RuntimeLibcallsInfo &RTLCI);
-
- /// Get the libcall routine name for the specified libcall.
- // FIXME: This should be removed. Only LibcallImpl should have a name.
- LLVM_ABI const char *getLibcallName(RTLIB::Libcall Call) const {
- // FIXME: Return StringRef
- return RTLIB::RuntimeLibcallsInfo::getLibcallImplName(LibcallImpls[Call])
- .data();
- }
-
- /// Return the lowering's selection of implementation call for \p Call
- LLVM_ABI RTLIB::LibcallImpl getLibcallImpl(RTLIB::Libcall Call) const {
- return LibcallImpls[Call];
- }
-
- /// Rename the default libcall routine name for the specified libcall.
- LLVM_ABI void setLibcallImpl(RTLIB::Libcall Call, RTLIB::LibcallImpl Impl) {
- LibcallImpls[Call] = Impl;
- }
-
- // FIXME: Remove this wrapper in favor of directly using
- // getLibcallImplCallingConv
- LLVM_ABI CallingConv::ID getLibcallCallingConv(RTLIB::Libcall Call) const {
- return RTLCI.LibcallImplCallingConvs[LibcallImpls[Call]];
- }
-
- /// Get the CallingConv that should be used for the specified libcall.
- LLVM_ABI CallingConv::ID
- getLibcallImplCallingConv(RTLIB::LibcallImpl Call) const {
- return RTLCI.LibcallImplCallingConvs[Call];
- }
-
- /// Return a function name compatible with RTLIB::MEMCPY, or nullptr if fully
- /// unsupported.
- LLVM_ABI StringRef getMemcpyName() const {
- RTLIB::LibcallImpl Memcpy = getLibcallImpl(RTLIB::MEMCPY);
- if (Memcpy != RTLIB::Unsupported)
- return RTLIB::RuntimeLibcallsInfo::getLibcallImplName(Memcpy);
-
- // Fallback to memmove if memcpy isn't available.
- return getLibcallName(RTLIB::MEMMOVE);
- }
-};
-
/// This base class for TargetLowering contains the SelectionDAG-independent
/// parts that can be used from the rest of CodeGen.
class LLVM_ABI TargetLoweringBase {
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.h b/llvm/include/llvm/IR/RuntimeLibcalls.h
index 8df94ffb980b6..e3f8fdd783e66 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.h
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.h
@@ -34,8 +34,6 @@
namespace llvm {
-class LibcallLoweringInfo;
-
template <> struct enum_iteration_traits<RTLIB::Libcall> {
static constexpr bool is_iterable = true;
};
@@ -44,6 +42,8 @@ template <> struct enum_iteration_traits<RTLIB::LibcallImpl> {
static constexpr bool is_iterable = true;
};
+class LibcallLoweringInfo;
+
namespace RTLIB {
// Return an iterator over all Libcall values.
@@ -248,6 +248,59 @@ struct RuntimeLibcallsInfo {
};
} // namespace RTLIB
+
+class LibcallLoweringInfo {
+private:
+ LLVM_ABI const RTLIB::RuntimeLibcallsInfo &RTLCI;
+ /// Stores the implementation choice for each each libcall.
+ LLVM_ABI RTLIB::LibcallImpl LibcallImpls[RTLIB::UNKNOWN_LIBCALL + 1] = {
+ RTLIB::Unsupported};
+
+public:
+ LLVM_ABI LibcallLoweringInfo(const RTLIB::RuntimeLibcallsInfo &RTLCI);
+
+ /// Get the libcall routine name for the specified libcall.
+ // FIXME: This should be removed. Only LibcallImpl should have a name.
+ LLVM_ABI const char *getLibcallName(RTLIB::Libcall Call) const {
+ // FIXME: Return StringRef
+ return RTLIB::RuntimeLibcallsInfo::getLibcallImplName(LibcallImpls[Call])
+ .data();
+ }
+
+ /// Return the lowering's selection of implementation call for \p Call
+ LLVM_ABI RTLIB::LibcallImpl getLibcallImpl(RTLIB::Libcall Call) const {
+ return LibcallImpls[Call];
+ }
+
+ /// Rename the default libcall routine name for the specified libcall.
+ LLVM_ABI void setLibcallImpl(RTLIB::Libcall Call, RTLIB::LibcallImpl Impl) {
+ LibcallImpls[Call] = Impl;
+ }
+
+ // FIXME: Remove this wrapper in favor of directly using
+ // getLibcallImplCallingConv
+ LLVM_ABI CallingConv::ID getLibcallCallingConv(RTLIB::Libcall Call) const {
+ return RTLCI.LibcallImplCallingConvs[LibcallImpls[Call]];
+ }
+
+ /// Get the CallingConv that should be used for the specified libcall.
+ LLVM_ABI CallingConv::ID
+ getLibcallImplCallingConv(RTLIB::LibcallImpl Call) const {
+ return RTLCI.LibcallImplCallingConvs[Call];
+ }
+
+ /// Return a function name compatible with RTLIB::MEMCPY, or nullptr if fully
+ /// unsupported.
+ LLVM_ABI StringRef getMemcpyName() const {
+ RTLIB::LibcallImpl Memcpy = getLibcallImpl(RTLIB::MEMCPY);
+ if (Memcpy != RTLIB::Unsupported)
+ return RTLIB::RuntimeLibcallsInfo::getLibcallImplName(Memcpy);
+
+ // Fallback to memmove if memcpy isn't available.
+ return getLibcallName(RTLIB::MEMMOVE);
+ }
+};
+
} // namespace llvm
#endif // LLVM_IR_RUNTIME_LIBCALLS_H
diff --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp b/llvm/lib/CodeGen/TargetLoweringBase.cpp
index bd6f447434cbd..1cc591c17f9c3 100644
--- a/llvm/lib/CodeGen/TargetLoweringBase.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp
@@ -695,21 +695,6 @@ ISD::CondCode TargetLoweringBase::getSoftFloatCmpLibcallPredicate(
}
}
-LibcallLoweringInfo::LibcallLoweringInfo(
- const RTLIB::RuntimeLibcallsInfo &RTLCI)
- : RTLCI(RTLCI) {
- // TODO: This should be generated with lowering predicates, and assert the
- // call is available.
- for (RTLIB::LibcallImpl Impl : RTLIB::libcall_impls()) {
- if (RTLCI.isAvailable(Impl)) {
- RTLIB::Libcall LC = RTLIB::RuntimeLibcallsInfo::getLibcallFromImpl(Impl);
- // FIXME: Hack, assume the first available libcall wins.
- if (LibcallImpls[LC] == RTLIB::Unsupported)
- LibcallImpls[LC] = Impl;
- }
- }
-}
-
/// NOTE: The TargetMachine owns TLOF.
TargetLoweringBase::TargetLoweringBase(const TargetMachine &tm)
: TM(tm),
diff --git a/llvm/lib/IR/RuntimeLibcalls.cpp b/llvm/lib/IR/RuntimeLibcalls.cpp
index 2fb01a4f95fea..1ac8b6bbd716a 100644
--- a/llvm/lib/IR/RuntimeLibcalls.cpp
+++ b/llvm/lib/IR/RuntimeLibcalls.cpp
@@ -152,3 +152,18 @@ RuntimeLibcallsInfo::getFunctionTy(LLVMContext &Ctx, const Triple &TT,
return {};
}
+
+LibcallLoweringInfo::LibcallLoweringInfo(
+ const RTLIB::RuntimeLibcallsInfo &RTLCI)
+ : RTLCI(RTLCI) {
+ // TODO: This should be generated with lowering predicates, and assert the
+ // call is available.
+ for (RTLIB::LibcallImpl Impl : RTLIB::libcall_impls()) {
+ if (RTLCI.isAvailable(Impl)) {
+ RTLIB::Libcall LC = RTLIB::RuntimeLibcallsInfo::getLibcallFromImpl(Impl);
+ // FIXME: Hack, assume the first available libcall wins.
+ if (LibcallImpls[LC] == RTLIB::Unsupported)
+ LibcallImpls[LC] = Impl;
+ }
+ }
+}
>From 226c6e5a7855f58ea6aa49fded511fbdb139d63c Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Sat, 25 Oct 2025 22:23:20 +0900
Subject: [PATCH 3/6] CodeGen: Move LibcallLoweringInfo to separate file
---
.../llvm/CodeGen/LibcallLoweringInfo.h | 65 +++++++++++++++++++
llvm/include/llvm/CodeGen/TargetLowering.h | 1 +
llvm/include/llvm/IR/RuntimeLibcalls.h | 52 ---------------
llvm/lib/CodeGen/CMakeLists.txt | 1 +
llvm/lib/CodeGen/LibcallLoweringInfo.cpp | 26 ++++++++
llvm/lib/IR/RuntimeLibcalls.cpp | 15 -----
6 files changed, 93 insertions(+), 67 deletions(-)
create mode 100644 llvm/include/llvm/CodeGen/LibcallLoweringInfo.h
create mode 100644 llvm/lib/CodeGen/LibcallLoweringInfo.cpp
diff --git a/llvm/include/llvm/CodeGen/LibcallLoweringInfo.h b/llvm/include/llvm/CodeGen/LibcallLoweringInfo.h
new file mode 100644
index 0000000000000..42ad3e65f5dd8
--- /dev/null
+++ b/llvm/include/llvm/CodeGen/LibcallLoweringInfo.h
@@ -0,0 +1,65 @@
+//===- LibcallLoweringInfo.h ------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/IR/RuntimeLibcalls.h"
+
+namespace llvm {
+
+class LibcallLoweringInfo {
+private:
+ LLVM_ABI const RTLIB::RuntimeLibcallsInfo &RTLCI;
+ /// Stores the implementation choice for each each libcall.
+ LLVM_ABI RTLIB::LibcallImpl LibcallImpls[RTLIB::UNKNOWN_LIBCALL + 1] = {
+ RTLIB::Unsupported};
+
+public:
+ LLVM_ABI LibcallLoweringInfo(const RTLIB::RuntimeLibcallsInfo &RTLCI);
+
+ /// Get the libcall routine name for the specified libcall.
+ // FIXME: This should be removed. Only LibcallImpl should have a name.
+ LLVM_ABI const char *getLibcallName(RTLIB::Libcall Call) const {
+ // FIXME: Return StringRef
+ return RTLIB::RuntimeLibcallsInfo::getLibcallImplName(LibcallImpls[Call])
+ .data();
+ }
+
+ /// Return the lowering's selection of implementation call for \p Call
+ LLVM_ABI RTLIB::LibcallImpl getLibcallImpl(RTLIB::Libcall Call) const {
+ return LibcallImpls[Call];
+ }
+
+ /// Rename the default libcall routine name for the specified libcall.
+ LLVM_ABI void setLibcallImpl(RTLIB::Libcall Call, RTLIB::LibcallImpl Impl) {
+ LibcallImpls[Call] = Impl;
+ }
+
+ // FIXME: Remove this wrapper in favor of directly using
+ // getLibcallImplCallingConv
+ LLVM_ABI CallingConv::ID getLibcallCallingConv(RTLIB::Libcall Call) const {
+ return RTLCI.LibcallImplCallingConvs[LibcallImpls[Call]];
+ }
+
+ /// Get the CallingConv that should be used for the specified libcall.
+ LLVM_ABI CallingConv::ID
+ getLibcallImplCallingConv(RTLIB::LibcallImpl Call) const {
+ return RTLCI.LibcallImplCallingConvs[Call];
+ }
+
+ /// Return a function name compatible with RTLIB::MEMCPY, or nullptr if fully
+ /// unsupported.
+ LLVM_ABI StringRef getMemcpyName() const {
+ RTLIB::LibcallImpl Memcpy = getLibcallImpl(RTLIB::MEMCPY);
+ if (Memcpy != RTLIB::Unsupported)
+ return RTLIB::RuntimeLibcallsInfo::getLibcallImplName(Memcpy);
+
+ // Fallback to memmove if memcpy isn't available.
+ return getLibcallName(RTLIB::MEMMOVE);
+ }
+};
+
+} // end namespace llvm
diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h b/llvm/include/llvm/CodeGen/TargetLowering.h
index 636d4f979ec65..2550c2bee5f71 100644
--- a/llvm/include/llvm/CodeGen/TargetLowering.h
+++ b/llvm/include/llvm/CodeGen/TargetLowering.h
@@ -29,6 +29,7 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/CodeGen/DAGCombine.h"
#include "llvm/CodeGen/ISDOpcodes.h"
+#include "llvm/CodeGen/LibcallLoweringInfo.h"
#include "llvm/CodeGen/LowLevelTypeUtils.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/CodeGen/RuntimeLibcallUtil.h"
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.h b/llvm/include/llvm/IR/RuntimeLibcalls.h
index e3f8fdd783e66..6d10e10fd9761 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.h
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.h
@@ -249,58 +249,6 @@ struct RuntimeLibcallsInfo {
} // namespace RTLIB
-class LibcallLoweringInfo {
-private:
- LLVM_ABI const RTLIB::RuntimeLibcallsInfo &RTLCI;
- /// Stores the implementation choice for each each libcall.
- LLVM_ABI RTLIB::LibcallImpl LibcallImpls[RTLIB::UNKNOWN_LIBCALL + 1] = {
- RTLIB::Unsupported};
-
-public:
- LLVM_ABI LibcallLoweringInfo(const RTLIB::RuntimeLibcallsInfo &RTLCI);
-
- /// Get the libcall routine name for the specified libcall.
- // FIXME: This should be removed. Only LibcallImpl should have a name.
- LLVM_ABI const char *getLibcallName(RTLIB::Libcall Call) const {
- // FIXME: Return StringRef
- return RTLIB::RuntimeLibcallsInfo::getLibcallImplName(LibcallImpls[Call])
- .data();
- }
-
- /// Return the lowering's selection of implementation call for \p Call
- LLVM_ABI RTLIB::LibcallImpl getLibcallImpl(RTLIB::Libcall Call) const {
- return LibcallImpls[Call];
- }
-
- /// Rename the default libcall routine name for the specified libcall.
- LLVM_ABI void setLibcallImpl(RTLIB::Libcall Call, RTLIB::LibcallImpl Impl) {
- LibcallImpls[Call] = Impl;
- }
-
- // FIXME: Remove this wrapper in favor of directly using
- // getLibcallImplCallingConv
- LLVM_ABI CallingConv::ID getLibcallCallingConv(RTLIB::Libcall Call) const {
- return RTLCI.LibcallImplCallingConvs[LibcallImpls[Call]];
- }
-
- /// Get the CallingConv that should be used for the specified libcall.
- LLVM_ABI CallingConv::ID
- getLibcallImplCallingConv(RTLIB::LibcallImpl Call) const {
- return RTLCI.LibcallImplCallingConvs[Call];
- }
-
- /// Return a function name compatible with RTLIB::MEMCPY, or nullptr if fully
- /// unsupported.
- LLVM_ABI StringRef getMemcpyName() const {
- RTLIB::LibcallImpl Memcpy = getLibcallImpl(RTLIB::MEMCPY);
- if (Memcpy != RTLIB::Unsupported)
- return RTLIB::RuntimeLibcallsInfo::getLibcallImplName(Memcpy);
-
- // Fallback to memmove if memcpy isn't available.
- return getLibcallName(RTLIB::MEMMOVE);
- }
-};
-
} // namespace llvm
#endif // LLVM_IR_RUNTIME_LIBCALLS_H
diff --git a/llvm/lib/CodeGen/CMakeLists.txt b/llvm/lib/CodeGen/CMakeLists.txt
index 4373c5397a3c6..1cf0b4964760b 100644
--- a/llvm/lib/CodeGen/CMakeLists.txt
+++ b/llvm/lib/CodeGen/CMakeLists.txt
@@ -88,6 +88,7 @@ add_llvm_component_library(LLVMCodeGen
LatencyPriorityQueue.cpp
LazyMachineBlockFrequencyInfo.cpp
LexicalScopes.cpp
+ LibcallLoweringInfo.cpp
LiveDebugVariables.cpp
LiveIntervals.cpp
LiveInterval.cpp
diff --git a/llvm/lib/CodeGen/LibcallLoweringInfo.cpp b/llvm/lib/CodeGen/LibcallLoweringInfo.cpp
new file mode 100644
index 0000000000000..5c1698cb6060e
--- /dev/null
+++ b/llvm/lib/CodeGen/LibcallLoweringInfo.cpp
@@ -0,0 +1,26 @@
+//===- LibcallLoweringInfo.cpp - Interface for runtime libcalls -----------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/CodeGen/LibcallLoweringInfo.h"
+
+using namespace llvm;
+
+LibcallLoweringInfo::LibcallLoweringInfo(
+ const RTLIB::RuntimeLibcallsInfo &RTLCI)
+ : RTLCI(RTLCI) {
+ // TODO: This should be generated with lowering predicates, and assert the
+ // call is available.
+ for (RTLIB::LibcallImpl Impl : RTLIB::libcall_impls()) {
+ if (RTLCI.isAvailable(Impl)) {
+ RTLIB::Libcall LC = RTLIB::RuntimeLibcallsInfo::getLibcallFromImpl(Impl);
+ // FIXME: Hack, assume the first available libcall wins.
+ if (LibcallImpls[LC] == RTLIB::Unsupported)
+ LibcallImpls[LC] = Impl;
+ }
+ }
+}
diff --git a/llvm/lib/IR/RuntimeLibcalls.cpp b/llvm/lib/IR/RuntimeLibcalls.cpp
index 1ac8b6bbd716a..2fb01a4f95fea 100644
--- a/llvm/lib/IR/RuntimeLibcalls.cpp
+++ b/llvm/lib/IR/RuntimeLibcalls.cpp
@@ -152,18 +152,3 @@ RuntimeLibcallsInfo::getFunctionTy(LLVMContext &Ctx, const Triple &TT,
return {};
}
-
-LibcallLoweringInfo::LibcallLoweringInfo(
- const RTLIB::RuntimeLibcallsInfo &RTLCI)
- : RTLCI(RTLCI) {
- // TODO: This should be generated with lowering predicates, and assert the
- // call is available.
- for (RTLIB::LibcallImpl Impl : RTLIB::libcall_impls()) {
- if (RTLCI.isAvailable(Impl)) {
- RTLIB::Libcall LC = RTLIB::RuntimeLibcallsInfo::getLibcallFromImpl(Impl);
- // FIXME: Hack, assume the first available libcall wins.
- if (LibcallImpls[LC] == RTLIB::Unsupported)
- LibcallImpls[LC] = Impl;
- }
- }
-}
>From 7795be6c6fa4f5a6a41b660923b2ec554a0d4e72 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Tue, 4 Nov 2025 22:22:03 -0800
Subject: [PATCH 4/6] Invert condition
---
llvm/include/llvm/CodeGen/LibcallLoweringInfo.h | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/llvm/include/llvm/CodeGen/LibcallLoweringInfo.h b/llvm/include/llvm/CodeGen/LibcallLoweringInfo.h
index 42ad3e65f5dd8..1b05574d35aca 100644
--- a/llvm/include/llvm/CodeGen/LibcallLoweringInfo.h
+++ b/llvm/include/llvm/CodeGen/LibcallLoweringInfo.h
@@ -54,11 +54,12 @@ class LibcallLoweringInfo {
/// unsupported.
LLVM_ABI StringRef getMemcpyName() const {
RTLIB::LibcallImpl Memcpy = getLibcallImpl(RTLIB::MEMCPY);
- if (Memcpy != RTLIB::Unsupported)
- return RTLIB::RuntimeLibcallsInfo::getLibcallImplName(Memcpy);
+ if (Memcpy == RTLIB::Unsupported) {
+ // Fallback to memmove if memcpy isn't available.
+ return getLibcallName(RTLIB::MEMMOVE);
+ }
- // Fallback to memmove if memcpy isn't available.
- return getLibcallName(RTLIB::MEMMOVE);
+ return RTLIB::RuntimeLibcallsInfo::getLibcallImplName(Memcpy);
}
};
>From a04f2e00439f9970df8262202f54ad1d0ab6e65b Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Wed, 5 Nov 2025 07:12:23 -0800
Subject: [PATCH 5/6] update test
---
.../Transforms/Util/DeclareRuntimeLibcalls/sincos_stret.ll | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/sincos_stret.ll b/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/sincos_stret.ll
index f0f09e97d9dba..57cb016bcb7f3 100644
--- a/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/sincos_stret.ll
+++ b/llvm/test/Transforms/Util/DeclareRuntimeLibcalls/sincos_stret.ll
@@ -7,14 +7,14 @@
; RUN: %if arm-registered-target %{ opt -S -passes=declare-runtime-libcalls -mtriple=armv7-apple-ios6 < %s | FileCheck -check-prefix=NONE %s %}
; RUN: %if x86-registered-target %{ opt -S -passes=declare-runtime-libcalls -mtriple=x86_64-apple-macos10.8 < %s | FileCheck -check-prefix=NONE %s %}
-; X64: declare <2 x float> @__sincosf_stret(float) [[SINCOS_ATTRS:#[0-9]+]]
; X64: declare { double, double } @__sincos_stret(double) [[SINCOS_ATTRS:#[0-9]+]]
+; X64: declare <2 x float> @__sincosf_stret(float) [[SINCOS_ATTRS:#[0-9]+]]
-; STRUCT: declare { float, float } @__sincosf_stret(float) [[SINCOS_ATTRS:#[0-9]+]]
; STRUCT: declare { double, double } @__sincos_stret(double) [[SINCOS_ATTRS:#[0-9]+]]
+; STRUCT: declare { float, float } @__sincosf_stret(float) [[SINCOS_ATTRS:#[0-9]+]]
-; SRET: declare void @__sincosf_stret(ptr sret({ float, float }) align 4, float) [[SINCOS_ATTRS:#[0-9]+]]
; SRET: declare void @__sincos_stret(ptr sret({ double, double }) align 4, double) [[SINCOS_ATTRS:#[0-9]+]]
+; SRET: declare void @__sincosf_stret(ptr sret({ float, float }) align 4, float) [[SINCOS_ATTRS:#[0-9]+]]
; CHECK: attributes [[SINCOS_ATTRS]] = { nocallback nofree nosync nounwind willreturn memory(errnomem: write) }
; SRET: attributes [[SINCOS_ATTRS]] = { nocallback nofree nosync nounwind willreturn memory(argmem: write, errnomem: write) }
>From dd74fdc49b3f11c8103b43fc6d5f6d3e73cb4b27 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Wed, 5 Nov 2025 08:20:34 -0800
Subject: [PATCH 6/6] Fix merge
---
llvm/include/llvm/CodeGen/LibcallLoweringInfo.h | 10 +++++-----
llvm/include/llvm/IR/RuntimeLibcalls.h | 11 -----------
2 files changed, 5 insertions(+), 16 deletions(-)
diff --git a/llvm/include/llvm/CodeGen/LibcallLoweringInfo.h b/llvm/include/llvm/CodeGen/LibcallLoweringInfo.h
index 1b05574d35aca..e8eceeed6aca6 100644
--- a/llvm/include/llvm/CodeGen/LibcallLoweringInfo.h
+++ b/llvm/include/llvm/CodeGen/LibcallLoweringInfo.h
@@ -50,16 +50,16 @@ class LibcallLoweringInfo {
return RTLCI.LibcallImplCallingConvs[Call];
}
- /// Return a function name compatible with RTLIB::MEMCPY, or nullptr if fully
- /// unsupported.
- LLVM_ABI StringRef getMemcpyName() const {
+ /// Return a function impl compatible with RTLIB::MEMCPY, or
+ /// RTLIB::Unsupported if fully unsupported.
+ RTLIB::LibcallImpl getMemcpyImpl() const {
RTLIB::LibcallImpl Memcpy = getLibcallImpl(RTLIB::MEMCPY);
if (Memcpy == RTLIB::Unsupported) {
// Fallback to memmove if memcpy isn't available.
- return getLibcallName(RTLIB::MEMMOVE);
+ return getLibcallImpl(RTLIB::MEMMOVE);
}
- return RTLIB::RuntimeLibcallsInfo::getLibcallImplName(Memcpy);
+ return Memcpy;
}
};
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.h b/llvm/include/llvm/IR/RuntimeLibcalls.h
index 6d10e10fd9761..78e4b1723aafa 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.h
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.h
@@ -114,17 +114,6 @@ struct RuntimeLibcallsInfo {
return ImplToLibcall[Impl];
}
- /// Return a function name compatible with RTLIB::MEMCPY, or nullptr if fully
- /// unsupported.
- RTLIB::LibcallImpl getMemcpyImpl() const {
- RTLIB::LibcallImpl Memcpy = getLibcallImpl(RTLIB::MEMCPY);
- if (Memcpy != RTLIB::Unsupported)
- return Memcpy;
-
- // Fallback to memmove if memcpy isn't available.
- return getLibcallImpl(RTLIB::MEMMOVE);
- }
-
unsigned getNumAvailableLibcallImpls() const {
return AvailableLibcallImpls.count();
}
More information about the llvm-commits
mailing list