[llvm] [ArgPromotion] Handle pointer arguments of recursive calls (PR #78735)
Vedant Paranjape via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 12 12:39:58 PDT 2024
================
@@ -422,13 +422,16 @@ doPromotion(Function *F, FunctionAnalysisManager &FAM,
/// Return true if we can prove that all callees pass in a valid pointer for the
/// specified function argument.
-static bool allCallersPassValidPointerForArgument(Argument *Arg,
- Align NeededAlign,
- uint64_t NeededDerefBytes) {
+static bool allCallersPassValidPointerForArgument(
+ Argument *Arg, SmallPtrSet<CallBase *, 4> &RecursiveCalls,
+ Align NeededAlign, uint64_t NeededDerefBytes) {
Function *Callee = Arg->getParent();
const DataLayout &DL = Callee->getParent()->getDataLayout();
APInt Bytes(64, NeededDerefBytes);
+ if (RecursiveCalls.size())
+ return true;
----------------
vedantparanjape-amd wrote:
> The code currently only looks for dereferenceable attributes on the caller (i.e. bar()), not the function itself.
Even this doesn't seem to work or manually adding a load i32 on ptr %x
```
define i32 @bar(ptr dereferenceable(32) %x, i32 %n, i32 %m) {
entry:
%tmp3 = call i32 @foo(ptr %x, i32 %n, i32 %m)
br label %return
return: ; preds = %entry
ret i32 %tmp3
}
```
https://github.com/llvm/llvm-project/pull/78735
More information about the llvm-commits
mailing list