[llvm] [ArgPromotion] Handle pointer arguments of recursive calls (PR #78735)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 12 01:27:21 PDT 2024


================
@@ -611,6 +639,33 @@ static bool findArgParts(Argument *Arg, const DataLayout &DL, AAResults &AAR,
       // unknown users
     }
 
+    auto *CB = dyn_cast<CallBase>(V);
+    Value *PtrArg = cast<Value>(U);
+    if (CB && PtrArg && CB->getCalledFunction() == CB->getFunction()) {
+      if (PtrArg != Arg) {
+        LLVM_DEBUG(dbgs() << "ArgPromotion of " << *Arg << " failed: "
+                          << "pointer offset is not equal to zero\n");
+        return false;
+      }
+
+      unsigned int ArgNo = Arg->getArgNo();
+      if (CB->getArgOperand(ArgNo) != Arg || U->getOperandNo() != ArgNo) {
----------------
nikic wrote:

The `CB->getArgOperand(ArgNo) != Arg`  check is redundant, `U->getOperandNo() != ArgNo` already does this more correctly.

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


More information about the llvm-commits mailing list