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

zhijian lin via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 25 08:11:18 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.
----------------
diggerlin wrote:

I created an NFC patch  [[NFC ]Add a helper function isTailCall for getting libcall in SelectionDAG](https://github.com/llvm/llvm-project/pull/155256/files), After the NFC is approved, I will modify the patch accordingly.

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


More information about the llvm-commits mailing list