[llvm] c5039c1 - [NFC] Refactor the SelectionDAG::getMemcmp etc with a existing helper function getRuntimeCallSDValueHelper (#184200)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 3 10:59:02 PST 2026
Author: zhijian lin
Date: 2026-03-03T13:58:57-05:00
New Revision: c5039c18482765b1499d94231c8b4c5e1a4be485
URL: https://github.com/llvm/llvm-project/commit/c5039c18482765b1499d94231c8b4c5e1a4be485
DIFF: https://github.com/llvm/llvm-project/commit/c5039c18482765b1499d94231c8b4c5e1a4be485.diff
LOG: [NFC] Refactor the SelectionDAG::getMemcmp etc with a existing helper function getRuntimeCallSDValueHelper (#184200)
Refactor the SelectionDAG::getMemcmp,
SelectionDAG::getStrcpy,SelectionDAG::getStrlen with a existing helper
function SelectionDAG::getRuntimeCallSDValueHelper.
Added:
Modified:
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Removed:
################################################################################
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 507cd27b7f501..6e37cd5804424 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -9449,84 +9449,34 @@ std::pair<SDValue, SDValue> SelectionDAG::getMemccpy(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 = Libcalls->getLibcallImpl(RTLIB::MEMCMP);
- if (MemcmpImpl == RTLIB::Unsupported)
- return {};
-
PointerType *PT = PointerType::getUnqual(*getContext());
TargetLowering::ArgListTy Args = {
{Mem0, PT},
{Mem1, PT},
{Size, getDataLayout().getIntPtrType(*getContext())}};
-
- TargetLowering::CallLoweringInfo CLI(*this);
- bool IsTailCall =
- isInTailCallPositionWrapper(CI, this, /*AllowReturnsFirstArg*/ true);
-
- CLI.setDebugLoc(dl)
- .setChain(Chain)
- .setLibCallee(
- Libcalls->getLibcallImplCallingConv(MemcmpImpl),
- Type::getInt32Ty(*getContext()),
- getExternalSymbol(MemcmpImpl, TLI->getPointerTy(getDataLayout())),
- std::move(Args))
- .setTailCall(IsTailCall);
-
- return TLI->LowerCallTo(CLI);
+ return getRuntimeCallSDValueHelper(Chain, dl, std::move(Args), CI,
+ RTLIB::MEMCMP, this, TLI);
}
std::pair<SDValue, SDValue> SelectionDAG::getStrcpy(SDValue Chain,
const SDLoc &dl,
SDValue Dst, SDValue Src,
const CallInst *CI) {
- RTLIB::LibcallImpl LCImpl = Libcalls->getLibcallImpl(RTLIB::STRCPY);
- if (LCImpl == RTLIB::Unsupported)
- return {};
-
PointerType *PT = PointerType::getUnqual(*getContext());
TargetLowering::ArgListTy Args = {{Dst, PT}, {Src, PT}};
-
- TargetLowering::CallLoweringInfo CLI(*this);
- bool IsTailCall =
- isInTailCallPositionWrapper(CI, this, /*AllowReturnsFirstArg=*/true);
-
- CLI.setDebugLoc(dl)
- .setChain(Chain)
- .setLibCallee(
- Libcalls->getLibcallImplCallingConv(LCImpl), CI->getType(),
- getExternalSymbol(LCImpl, TLI->getPointerTy(getDataLayout())),
- std::move(Args))
- .setTailCall(IsTailCall);
-
- return TLI->LowerCallTo(CLI);
+ return getRuntimeCallSDValueHelper(Chain, dl, std::move(Args), CI,
+ RTLIB::STRCPY, this, TLI);
}
std::pair<SDValue, SDValue> SelectionDAG::getStrlen(SDValue Chain,
const SDLoc &dl,
SDValue Src,
const CallInst *CI) {
- RTLIB::LibcallImpl StrlenImpl = Libcalls->getLibcallImpl(RTLIB::STRLEN);
- if (StrlenImpl == RTLIB::Unsupported)
- return {};
-
// Emit a library call.
TargetLowering::ArgListTy Args = {
{Src, PointerType::getUnqual(*getContext())}};
-
- TargetLowering::CallLoweringInfo CLI(*this);
- bool IsTailCall =
- isInTailCallPositionWrapper(CI, this, /*AllowReturnsFirstArg*/ true);
-
- CLI.setDebugLoc(dl)
- .setChain(Chain)
- .setLibCallee(Libcalls->getLibcallImplCallingConv(StrlenImpl),
- CI->getType(),
- getExternalSymbol(
- StrlenImpl, TLI->getProgramPointerTy(getDataLayout())),
- std::move(Args))
- .setTailCall(IsTailCall);
-
- return TLI->LowerCallTo(CLI);
+ return getRuntimeCallSDValueHelper(Chain, dl, std::move(Args), CI,
+ RTLIB::STRLEN, this, TLI);
}
SDValue SelectionDAG::getMemcpy(
More information about the llvm-commits
mailing list