[llvm] [ArgPromotion] Consider InvokeInst in Caller alias analysis (PR #110335)

via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 27 15:46:03 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: Hari Limaye (hazzlim)

<details>
<summary>Changes</summary>

Check that all users of a Function are CallBase rather than CallInst when performing alias analysis using actual arguments in the calling function, as this check is also valid for Invoke instructions.

This allows replacing the existing check with an assert, as the Function only being used by CallBase derived instructions is a precondition of the transform.

This addresses post-commit review on #<!-- -->106216.

---
Full diff: https://github.com/llvm/llvm-project/pull/110335.diff


1 Files Affected:

- (modified) llvm/lib/Transforms/IPO/ArgumentPromotion.cpp (+2-4) 


``````````diff
diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
index 90e8c39e5a90df..590362bdcad2cd 100644
--- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
+++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
@@ -491,10 +491,8 @@ 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);
-    if (!Call)
-      return false;
+    assert(isa<CallBase>(U) && "Expected all users of Function to be CallBase");
+    CallBase *Call = cast<CallBase>(U);
 
     MemoryLocation Loc =
         MemoryLocation::getForArgument(Call, Arg->getArgNo(), nullptr);

``````````

</details>


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


More information about the llvm-commits mailing list