[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.
+static bool callDoesNotModifyArg(Function *F, unsigned ArgNo,
+                                 FunctionAnalysisManager &FAM) {
+  // Find all Users of F that are Calls, and see if they may modify Arg.
+  for (User *U : F->users()) {
+    auto *Call = dyn_cast<CallInst>(U);
+    if (!Call)
+      continue;
----------------
efriedma-quic wrote:

If we find an unexpected use of the function, should we bail?

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


More information about the llvm-commits mailing list