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

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 27 05:17:30 PDT 2024


================
@@ -485,11 +485,36 @@ static bool allCallersPassValidPointerForArgument(
   });
 }
 
+// Try to prove that all Calls to F do not modify the memory pointed to by Arg,
+// using alias analysis local to each caller of F.
+static bool isArgUnmodifiedByAllCalls(Argument *Arg,
+                                      FunctionAnalysisManager &FAM) {
+  for (User *U : Arg->getParent()->users()) {
+
+    // Bail if we find an unexpected (non CallInst) use of the function.
+    auto *Call = dyn_cast<CallInst>(U);
----------------
nikic wrote:

Why is this checking for `CallInst` rather than `CallBase`? This should also work for invokes, right?

And I think then you could also replace it with an assert, as the function only being used as CallBase callee is a precondition of trying the transform in the first place.

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


More information about the llvm-commits mailing list