[llvm] [ArgPromotion] Perform alias analysis on actual arguments of Calls (PR #106216)

Hari Limaye via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 24 05:41:35 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);
+  }
----------------
hazzlim wrote:

No worries! Refining with the Size of the memory accessed through the pointer (given that it is already calculated) does seem like a reasonable thing to do, even though getModRefInfo does not currently make much use of it. I'll leave this in if that makes sense to you?



https://github.com/llvm/llvm-project/pull/106216


More information about the llvm-commits mailing list