[llvm] [ArgPromotion] Handle pointer arguments of recursive calls (PR #78735)
Vedant Paranjape via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 11 06:01:26 PDT 2024
================
@@ -610,6 +638,45 @@ 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()) {
+ Type *PtrTy = PtrArg->getType();
+ APInt Offset(DL.getIndexTypeSizeInBits(PtrTy), 0);
+ PtrArg = PtrArg->stripAndAccumulateConstantOffsets(
+ DL, Offset,
+ /* AllowNonInbounds= */ true);
+ if (PtrArg != Arg)
+ return false;
+
+ if (Offset.getSignificantBits() >= 64)
+ return false;
+
+ int64_t Off = Offset.getSExtValue();
+ if (Off) {
+ LLVM_DEBUG(dbgs() << "ArgPromotion of " << *Arg << " failed: "
+ << "pointer offset is not equal to zero\n");
+ return false;
+ }
----------------
vedantparanjape-amd wrote:
yes, I did this. Was just about to push it. Thanks!
https://github.com/llvm/llvm-project/pull/78735
More information about the llvm-commits
mailing list