[llvm] [ArgPromotion] Perform alias analysis on actual arguments of Calls (PR #106216)
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 29 14:54:38 PDT 2024
================
@@ -745,6 +748,33 @@ static bool areTypesABICompatible(ArrayRef<Type *> Types, const Function &F,
});
}
+// Try to prove that all Calls to F do not modify the memory pointed to by Arg.
+// This can provide us with more opportunities to perform Argument Promotion in
+// cases where simply looking at a Function's instructions is insufficient to
+// prove that the pointer argument is not invalidated before all loads from it.
----------------
efriedma-quic wrote:
So if I'm following correctly, you're doing basically the same analysis in two different ways. The first way is using local to the caller: if the pointed-to memory isn't modified at all, we're fine.
can prove a lack of aliasing, we're done. The second way is local to the callee: if the argument memory can't ever be modified before it's loaded, no matter what the arguments are, we're fine.
In theory, you could do an interprocedural analysis... but it would be expensive to compute, and ArgumentPromotion doesn't have infrastructure for that. So I guess this is fine, but it could use better comments explaining that you're using two different approaches to compute the same thing.
Also, is there some reason callDoesNotModifyArg() needs to run before we reach the relevant bit of findArgParts()? If the two checks were together, it would be more obvious they're related.
https://github.com/llvm/llvm-project/pull/106216
More information about the llvm-commits
mailing list