[llvm] [ArgPromotion] Perform alias analysis on actual arguments of Calls (PR #106216)
Eli Friedman via llvm-commits
llvm-commits at lists.llvm.org
Thu Sep 19 15:35:00 PDT 2024
================
@@ -716,10 +744,22 @@ static bool findArgParts(Argument *Arg, const DataLayout &DL, AAResults &AAR,
return true;
// Okay, now we know that the argument is only used by load instructions, and
- // it is safe to unconditionally perform all of them. Use alias analysis to
- // check to see if the pointer is guaranteed to not be modified from entry of
- // the function to each of the load instructions.
+ // it is safe to unconditionally perform all of them.
+
+ // If we can determine that no call to the Function modifies the memory region
+ // accessed through Arg, through alias analysis using actual arguments in the
+ // callers, we know that it is guaranteed to be safe to promote the argument.
+
+ // Compute the size of the memory region accessed by the Loads through Arg.
+ LocationSize Size = LocationSize::precise(0);
+ for (LoadInst *Load : Loads) {
+ Size = Size.unionWith(MemoryLocation::get(Load).Size);
+ }
----------------
efriedma-quic wrote:
This loop doesn't compute what the comment says it does. Say you have an array of 3 uint32_t to promote; that's 12 bytes. This computes a size of 4 bytes.
https://github.com/llvm/llvm-project/pull/106216
More information about the llvm-commits
mailing list