[llvm] [PowerPC] using milicode call for strlen instead of lib call (PR #153600)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 19 09:11:17 PDT 2025
================
@@ -9050,6 +9050,42 @@ SelectionDAG::getMemcmp(SDValue Chain, const SDLoc &dl, SDValue Mem0,
return TLI->LowerCallTo(CLI);
}
+std::pair<SDValue, SDValue> SelectionDAG::getStrlen(SDValue Chain,
+ const SDLoc &dl,
+ SDValue Src,
+ const CallInst *CI) {
+ const char *LibCallName = TLI->getLibcallName(RTLIB::STRLEN);
+ if (!LibCallName)
+ return {};
+
+ // Emit a library call.
+ auto GetEntry = [](Type *Ty, SDValue &SDV) {
+ TargetLowering::ArgListEntry E;
+ E.Ty = Ty;
+ E.Node = SDV;
+ return E;
+ };
+
+ PointerType *PT = PointerType::getUnqual(*getContext());
+ TargetLowering::ArgListTy Args = {GetEntry(PT, Src)};
+
+ TargetLowering::CallLoweringInfo CLI(*this);
+ bool IsTailCall = false;
+ bool ReturnsFirstArg = CI && funcReturnsFirstArgOfCall(*CI);
+ IsTailCall = CI && CI->isTailCall() &&
+ isInTailCallPosition(*CI, getTarget(), ReturnsFirstArg);
----------------
arsenm wrote:
I assume none of the tail call handling is untested like the other functions? Can this code be shared between these similar calls?
https://github.com/llvm/llvm-project/pull/153600
More information about the llvm-commits
mailing list