[llvm] [PowerPC] using milicode call for strlen instead of lib call (PR #153600)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 22 18:24:49 PDT 2025


================
@@ -9050,6 +9050,37 @@ 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);
+
+  //  TODO: propagate tail call flag for targets where that is safe. Note
+  //  that it is not safe on AIX which is the only current target.
----------------
arsenm wrote:

I meant can you just factor out the existing check into a helper function that all the cases use

https://github.com/llvm/llvm-project/pull/153600


More information about the llvm-commits mailing list