@@ -9094,6 +9094,43 @@ SelectionDAG::getMemcmp(SDValue Chain, const SDLoc &dl, SDValue Mem0,
90949094 return TLI->LowerCallTo(CLI);
90959095}
90969096
9097+ std::pair<SDValue, SDValue> SelectionDAG::getStrlen(SDValue Chain,
9098+ const SDLoc &dl,
9099+ SDValue Src,
9100+ const CallInst *CI) {
9101+ const char *LibCallName = TLI->getLibcallName(RTLIB::STRLEN);
9102+ if (!LibCallName)
9103+ return {};
9104+
9105+ // Emit a library call.
9106+ auto GetEntry = [](Type *Ty, SDValue &SDV) {
9107+ TargetLowering::ArgListEntry E;
9108+ E.Ty = Ty;
9109+ E.Node = SDV;
9110+ return E;
9111+ };
9112+
9113+ PointerType *PT = PointerType::getUnqual(*getContext());
9114+ TargetLowering::ArgListTy Args = {GetEntry(PT, Src)};
9115+
9116+ TargetLowering::CallLoweringInfo CLI(*this);
9117+ bool IsTailCall = false;
9118+ bool ReturnsFirstArg = CI && funcReturnsFirstArgOfCall(*CI);
9119+ IsTailCall = CI && CI->isTailCall() &&
9120+ isInTailCallPosition(*CI, getTarget(), ReturnsFirstArg);
9121+
9122+ CLI.setDebugLoc(dl)
9123+ .setChain(Chain)
9124+ .setLibCallee(
9125+ TLI->getLibcallCallingConv(RTLIB::STRLEN),
9126+ Type::getInt32Ty(*getContext()),
9127+ getExternalSymbol(LibCallName, TLI->getPointerTy(getDataLayout())),
9128+ std::move(Args))
9129+ .setTailCall(IsTailCall);
9130+
9131+ return TLI->LowerCallTo(CLI);
9132+ }
9133+
90979134SDValue SelectionDAG::getMemcpy(
90989135 SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size,
90999136 Align Alignment, bool isVol, bool AlwaysInline, const CallInst *CI,
0 commit comments