-
Notifications
You must be signed in to change notification settings - Fork 12.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ArgPromotion] Consider InvokeInst in Caller alias analysis #110335
Conversation
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 llvm#106216.
@llvm/pr-subscribers-llvm-transforms Author: Hari Limaye (hazzlim) ChangesCheck 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:
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);
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to also test that the alias analysis based transform also works with invoked now.
assert(isa<CallBase>(U) && "Expected all users of Function to be CallBase"); | ||
CallBase *Call = cast<CallBase>(U); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert(isa<CallBase>(U) && "Expected all users of Function to be CallBase"); | |
CallBase *Call = cast<CallBase>(U); | |
auto *Call = cast<CallBase>(U); |
cast
performs an implicit isa
assert.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice - updated to remove the superfluous assert(), and added some tests for invoke instructions.
- Remove superfluous assert() - Add tests for invoke instructions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
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.