[llvm] [ArgPromotion] Consider InvokeInst in Caller alias analysis (PR #110335)
Hari Limaye via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 27 15:45:30 PDT 2024
https://github.com/hazzlim created https://github.com/llvm/llvm-project/pull/110335
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.
>From 9855319f3df0ff3c16a1755e098aa1e954fb26be Mon Sep 17 00:00:00 2001
From: Hari Limaye <hari.limaye at arm.com>
Date: Fri, 27 Sep 2024 22:32:33 +0000
Subject: [PATCH] [ArgPromotion] Consider InvokeInst in Caller alias analysis
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.
---
llvm/lib/Transforms/IPO/ArgumentPromotion.cpp | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
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);
More information about the llvm-commits
mailing list