[llvm] [ArgPromotion] Handle pointer arguments of recursive calls (PR #78735)
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 9 12:36:02 PDT 2024
================
@@ -610,13 +610,78 @@ static bool findArgParts(Argument *Arg, const DataLayout &DL, AAResults &AAR,
// unknown users
}
+ auto *CB = dyn_cast<CallBase>(V);
+ Value *PtrArg = cast<Value>(U);
+ if (IsRecursive && CB && PtrArg) {
+ Type *PtrTy = PtrArg->getType();
+ Align PtrAlign = PtrArg->getPointerAlignment(DL);
+ APInt Offset(DL.getIndexTypeSizeInBits(PtrArg->getType()), 0);
+ PtrArg = PtrArg->stripAndAccumulateConstantOffsets(
----------------
efriedma-quic wrote:
If the offset isn't zero, there's no way to make the recursion work correctly in general: the overall offset is multiplied by the number of levels of recursion, and you can only promote a finite number of bytes.
Given that, we don't need to track the call in ArgParts at all. You just need to check that the offset is zero, and that we're passing the pointer to the corresponding argument of the call.
https://github.com/llvm/llvm-project/pull/78735
More information about the llvm-commits
mailing list