[llvm] aca2783 - DAG: Get libcall info from LibcallLowering in more places (#176836)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 20 03:47:27 PST 2026
Author: Matt Arsenault
Date: 2026-01-20T12:47:22+01:00
New Revision: aca27838401599c78427ef55bfc836a326ea5ef7
URL: https://github.com/llvm/llvm-project/commit/aca27838401599c78427ef55bfc836a326ea5ef7
DIFF: https://github.com/llvm/llvm-project/commit/aca27838401599c78427ef55bfc836a326ea5ef7.diff
LOG: DAG: Get libcall info from LibcallLowering in more places (#176836)
Avoid using TargetLowering functions
Added:
Modified:
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
llvm/lib/Target/ARM/ARMSelectionDAGInfo.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 4f1054af481d9..c7c36ac56a8ab 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -9190,7 +9190,7 @@ getRuntimeCallSDValueHelper(SDValue Chain, const SDLoc &dl,
TargetLowering::ArgListTy &&Args,
const CallInst *CI, RTLIB::Libcall Call,
SelectionDAG *DAG, const TargetLowering *TLI) {
- RTLIB::LibcallImpl LCImpl = TLI->getLibcallImpl(Call);
+ RTLIB::LibcallImpl LCImpl = DAG->getLibcalls().getLibcallImpl(Call);
if (LCImpl == RTLIB::Unsupported)
return {};
@@ -9203,8 +9203,8 @@ getRuntimeCallSDValueHelper(SDValue Chain, const SDLoc &dl,
CLI.setDebugLoc(dl)
.setChain(Chain)
- .setLibCallee(TLI->getLibcallImplCallingConv(LCImpl), CI->getType(),
- Callee, std::move(Args))
+ .setLibCallee(DAG->getLibcalls().getLibcallImplCallingConv(LCImpl),
+ CI->getType(), Callee, std::move(Args))
.setTailCall(IsTailCall);
return TLI->LowerCallTo(CLI);
@@ -9223,7 +9223,7 @@ std::pair<SDValue, SDValue> SelectionDAG::getStrstr(SDValue Chain,
std::pair<SDValue, SDValue>
SelectionDAG::getMemcmp(SDValue Chain, const SDLoc &dl, SDValue Mem0,
SDValue Mem1, SDValue Size, const CallInst *CI) {
- RTLIB::LibcallImpl MemcmpImpl = getLibcalls().getLibcallImpl(RTLIB::MEMCMP);
+ RTLIB::LibcallImpl MemcmpImpl = Libcalls->getLibcallImpl(RTLIB::MEMCMP);
if (MemcmpImpl == RTLIB::Unsupported)
return {};
@@ -9240,7 +9240,7 @@ SelectionDAG::getMemcmp(SDValue Chain, const SDLoc &dl, SDValue Mem0,
CLI.setDebugLoc(dl)
.setChain(Chain)
.setLibCallee(
- getLibcalls().getLibcallImplCallingConv(MemcmpImpl),
+ Libcalls->getLibcallImplCallingConv(MemcmpImpl),
Type::getInt32Ty(*getContext()),
getExternalSymbol(MemcmpImpl, TLI->getPointerTy(getDataLayout())),
std::move(Args))
@@ -9253,7 +9253,7 @@ std::pair<SDValue, SDValue> SelectionDAG::getStrcpy(SDValue Chain,
const SDLoc &dl,
SDValue Dst, SDValue Src,
const CallInst *CI) {
- RTLIB::LibcallImpl LCImpl = TLI->getLibcallImpl(RTLIB::STRCPY);
+ RTLIB::LibcallImpl LCImpl = Libcalls->getLibcallImpl(RTLIB::STRCPY);
if (LCImpl == RTLIB::Unsupported)
return {};
@@ -9267,7 +9267,7 @@ std::pair<SDValue, SDValue> SelectionDAG::getStrcpy(SDValue Chain,
CLI.setDebugLoc(dl)
.setChain(Chain)
.setLibCallee(
- TLI->getLibcallImplCallingConv(LCImpl), CI->getType(),
+ Libcalls->getLibcallImplCallingConv(LCImpl), CI->getType(),
getExternalSymbol(LCImpl, TLI->getPointerTy(getDataLayout())),
std::move(Args))
.setTailCall(IsTailCall);
@@ -9279,7 +9279,7 @@ std::pair<SDValue, SDValue> SelectionDAG::getStrlen(SDValue Chain,
const SDLoc &dl,
SDValue Src,
const CallInst *CI) {
- RTLIB::LibcallImpl StrlenImpl = getLibcalls().getLibcallImpl(RTLIB::STRLEN);
+ RTLIB::LibcallImpl StrlenImpl = Libcalls->getLibcallImpl(RTLIB::STRLEN);
if (StrlenImpl == RTLIB::Unsupported)
return {};
@@ -9293,7 +9293,8 @@ std::pair<SDValue, SDValue> SelectionDAG::getStrlen(SDValue Chain,
CLI.setDebugLoc(dl)
.setChain(Chain)
- .setLibCallee(TLI->getLibcallImplCallingConv(StrlenImpl), CI->getType(),
+ .setLibCallee(Libcalls->getLibcallImplCallingConv(StrlenImpl),
+ CI->getType(),
getExternalSymbol(
StrlenImpl, TLI->getProgramPointerTy(getDataLayout())),
std::move(Args))
@@ -9372,7 +9373,7 @@ SDValue SelectionDAG::getMemcpy(
CLI.setDebugLoc(dl)
.setChain(Chain)
.setLibCallee(
- getLibcalls().getLibcallImplCallingConv(MemCpyImpl),
+ Libcalls->getLibcallImplCallingConv(MemCpyImpl),
Dst.getValueType().getTypeForEVT(*getContext()),
getExternalSymbol(MemCpyImpl, TLI->getPointerTy(getDataLayout())),
std::move(Args))
@@ -9398,7 +9399,7 @@ SDValue SelectionDAG::getAtomicMemcpy(SDValue Chain, const SDLoc &dl,
RTLIB::Libcall LibraryCall =
RTLIB::getMEMCPY_ELEMENT_UNORDERED_ATOMIC(ElemSz);
- RTLIB::LibcallImpl LibcallImpl = getLibcalls().getLibcallImpl(LibraryCall);
+ RTLIB::LibcallImpl LibcallImpl = Libcalls->getLibcallImpl(LibraryCall);
if (LibcallImpl == RTLIB::Unsupported)
report_fatal_error("Unsupported element size");
@@ -9406,7 +9407,7 @@ SDValue SelectionDAG::getAtomicMemcpy(SDValue Chain, const SDLoc &dl,
CLI.setDebugLoc(dl)
.setChain(Chain)
.setLibCallee(
- getLibcalls().getLibcallImplCallingConv(LibcallImpl),
+ Libcalls->getLibcallImplCallingConv(LibcallImpl),
Type::getVoidTy(*getContext()),
getExternalSymbol(LibcallImpl, TLI->getPointerTy(getDataLayout())),
std::move(Args))
@@ -9465,7 +9466,7 @@ SDValue SelectionDAG::getMemmove(SDValue Chain, const SDLoc &dl, SDValue Dst,
// FIXME: pass in SDLoc
TargetLowering::CallLoweringInfo CLI(*this);
- RTLIB::LibcallImpl MemmoveImpl = getLibcalls().getLibcallImpl(RTLIB::MEMMOVE);
+ RTLIB::LibcallImpl MemmoveImpl = Libcalls->getLibcallImpl(RTLIB::MEMMOVE);
bool IsTailCall = false;
if (OverrideTailCall.has_value()) {
@@ -9478,7 +9479,7 @@ SDValue SelectionDAG::getMemmove(SDValue Chain, const SDLoc &dl, SDValue Dst,
CLI.setDebugLoc(dl)
.setChain(Chain)
.setLibCallee(
- getLibcalls().getLibcallImplCallingConv(MemmoveImpl),
+ Libcalls->getLibcallImplCallingConv(MemmoveImpl),
Dst.getValueType().getTypeForEVT(*getContext()),
getExternalSymbol(MemmoveImpl, TLI->getPointerTy(getDataLayout())),
std::move(Args))
@@ -9504,7 +9505,7 @@ SDValue SelectionDAG::getAtomicMemmove(SDValue Chain, const SDLoc &dl,
RTLIB::Libcall LibraryCall =
RTLIB::getMEMMOVE_ELEMENT_UNORDERED_ATOMIC(ElemSz);
- RTLIB::LibcallImpl LibcallImpl = getLibcalls().getLibcallImpl(LibraryCall);
+ RTLIB::LibcallImpl LibcallImpl = Libcalls->getLibcallImpl(LibraryCall);
if (LibcallImpl == RTLIB::Unsupported)
report_fatal_error("Unsupported element size");
@@ -9512,7 +9513,7 @@ SDValue SelectionDAG::getAtomicMemmove(SDValue Chain, const SDLoc &dl,
CLI.setDebugLoc(dl)
.setChain(Chain)
.setLibCallee(
- getLibcalls().getLibcallImplCallingConv(LibcallImpl),
+ Libcalls->getLibcallImplCallingConv(LibcallImpl),
Type::getVoidTy(*getContext()),
getExternalSymbol(LibcallImpl, TLI->getPointerTy(getDataLayout())),
std::move(Args))
@@ -9576,7 +9577,7 @@ SDValue SelectionDAG::getMemset(SDValue Chain, const SDLoc &dl, SDValue Dst,
// FIXME: pass in SDLoc
CLI.setDebugLoc(dl).setChain(Chain);
- RTLIB::LibcallImpl BzeroImpl = TLI->getLibcallImpl(RTLIB::BZERO);
+ RTLIB::LibcallImpl BzeroImpl = Libcalls->getLibcallImpl(RTLIB::BZERO);
bool UseBZero = BzeroImpl != RTLIB::Unsupported && isNullConstant(Src);
// If zeroing out and bzero is present, use it.
@@ -9585,22 +9586,22 @@ SDValue SelectionDAG::getMemset(SDValue Chain, const SDLoc &dl, SDValue Dst,
Args.emplace_back(Dst, PointerType::getUnqual(Ctx));
Args.emplace_back(Size, DL.getIntPtrType(Ctx));
CLI.setLibCallee(
- TLI->getLibcallImplCallingConv(BzeroImpl), Type::getVoidTy(Ctx),
+ Libcalls->getLibcallImplCallingConv(BzeroImpl), Type::getVoidTy(Ctx),
getExternalSymbol(BzeroImpl, TLI->getPointerTy(DL)), std::move(Args));
} else {
- RTLIB::LibcallImpl MemsetImpl = TLI->getLibcallImpl(RTLIB::MEMSET);
+ RTLIB::LibcallImpl MemsetImpl = Libcalls->getLibcallImpl(RTLIB::MEMSET);
TargetLowering::ArgListTy Args;
Args.emplace_back(Dst, PointerType::getUnqual(Ctx));
Args.emplace_back(Src, Src.getValueType().getTypeForEVT(Ctx));
Args.emplace_back(Size, DL.getIntPtrType(Ctx));
- CLI.setLibCallee(TLI->getLibcallImplCallingConv(MemsetImpl),
+ CLI.setLibCallee(Libcalls->getLibcallImplCallingConv(MemsetImpl),
Dst.getValueType().getTypeForEVT(Ctx),
getExternalSymbol(MemsetImpl, TLI->getPointerTy(DL)),
std::move(Args));
}
- RTLIB::LibcallImpl MemsetImpl = TLI->getLibcallImpl(RTLIB::MEMSET);
+ RTLIB::LibcallImpl MemsetImpl = Libcalls->getLibcallImpl(RTLIB::MEMSET);
bool LowersToMemset = MemsetImpl == RTLIB::impl_memset;
// If we're going to use bzero, make sure not to tail call unless the
@@ -9629,7 +9630,7 @@ SDValue SelectionDAG::getAtomicMemset(SDValue Chain, const SDLoc &dl,
RTLIB::Libcall LibraryCall =
RTLIB::getMEMSET_ELEMENT_UNORDERED_ATOMIC(ElemSz);
- RTLIB::LibcallImpl LibcallImpl = TLI->getLibcallImpl(LibraryCall);
+ RTLIB::LibcallImpl LibcallImpl = Libcalls->getLibcallImpl(LibraryCall);
if (LibcallImpl == RTLIB::Unsupported)
report_fatal_error("Unsupported element size");
@@ -9637,7 +9638,7 @@ SDValue SelectionDAG::getAtomicMemset(SDValue Chain, const SDLoc &dl,
CLI.setDebugLoc(dl)
.setChain(Chain)
.setLibCallee(
- TLI->getLibcallImplCallingConv(LibcallImpl),
+ Libcalls->getLibcallImplCallingConv(LibcallImpl),
Type::getVoidTy(*getContext()),
getExternalSymbol(LibcallImpl, TLI->getPointerTy(getDataLayout())),
std::move(Args))
@@ -14369,7 +14370,7 @@ SDValue SelectionDAG::makeStateFunctionCall(unsigned LibFunc, SDValue Ptr,
TargetLowering::ArgListTy Args;
Args.emplace_back(Ptr, Ptr.getValueType().getTypeForEVT(*getContext()));
RTLIB::LibcallImpl LibcallImpl =
- TLI->getLibcallImpl(static_cast<RTLIB::Libcall>(LibFunc));
+ Libcalls->getLibcallImpl(static_cast<RTLIB::Libcall>(LibFunc));
if (LibcallImpl == RTLIB::Unsupported)
reportFatalUsageError("emitting call to unsupported libcall");
@@ -14377,7 +14378,7 @@ SDValue SelectionDAG::makeStateFunctionCall(unsigned LibFunc, SDValue Ptr,
getExternalSymbol(LibcallImpl, TLI->getPointerTy(getDataLayout()));
TargetLowering::CallLoweringInfo CLI(*this);
CLI.setDebugLoc(DLoc).setChain(InChain).setLibCallee(
- TLI->getLibcallImplCallingConv(LibcallImpl),
+ Libcalls->getLibcallImplCallingConv(LibcallImpl),
Type::getVoidTy(*getContext()), Callee, std::move(Args));
return TLI->LowerCallTo(CLI).second;
}
diff --git a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
index d34f3211dc463..d66d6f5a99416 100644
--- a/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
@@ -1308,7 +1308,8 @@ void SelectionDAGBuilder::visitGCRelocate(const GCRelocateInst &Relocate) {
void SelectionDAGBuilder::LowerDeoptimizeCall(const CallInst *CI) {
const auto &TLI = DAG.getTargetLoweringInfo();
- RTLIB::LibcallImpl DeoptImpl = TLI.getLibcallImpl(RTLIB::DEOPTIMIZE);
+ RTLIB::LibcallImpl DeoptImpl =
+ DAG.getLibcalls().getLibcallImpl(RTLIB::DEOPTIMIZE);
if (DeoptImpl == RTLIB::Unsupported) {
DAG.getContext()->emitError("no deoptimize libcall available");
return;
diff --git a/llvm/lib/Target/ARM/ARMSelectionDAGInfo.cpp b/llvm/lib/Target/ARM/ARMSelectionDAGInfo.cpp
index d31adfb98cba9..475fad2d02a12 100644
--- a/llvm/lib/Target/ARM/ARMSelectionDAGInfo.cpp
+++ b/llvm/lib/Target/ARM/ARMSelectionDAGInfo.cpp
@@ -138,19 +138,19 @@ SDValue ARMSelectionDAGInfo::EmitSpecializedLibcall(
} AEABILibcall;
switch (LC) {
case RTLIB::MEMCPY:
- if (TLI->getLibcallImpl(LC) != RTLIB::impl___aeabi_memcpy)
+ if (DAG.getLibcalls().getLibcallImpl(LC) != RTLIB::impl___aeabi_memcpy)
return SDValue();
AEABILibcall = AEABI_MEMCPY;
break;
case RTLIB::MEMMOVE:
- if (TLI->getLibcallImpl(LC) != RTLIB::impl___aeabi_memmove)
+ if (DAG.getLibcalls().getLibcallImpl(LC) != RTLIB::impl___aeabi_memmove)
return SDValue();
AEABILibcall = AEABI_MEMMOVE;
break;
case RTLIB::MEMSET:
- if (TLI->getLibcallImpl(LC) != RTLIB::impl___aeabi_memset)
+ if (DAG.getLibcalls().getLibcallImpl(LC) != RTLIB::impl___aeabi_memset)
return SDValue();
AEABILibcall = AEABI_MEMSET;
More information about the llvm-commits
mailing list