-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[AMDGPU] Update PromoteAlloca to handle GEPs with variable offset. #122342
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
Changes from 1 commit
1093642
9b7403a
d443b33
13a43bd
bf8a22d
3e8e15f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -122,6 +122,34 @@ define amdgpu_vs void @promote_load_from_store_aggr() #0 { | |||||
| ret void | ||||||
| } | ||||||
|
|
||||||
| %Block4 = type { [2 x i32], i32 } | ||||||
| @block4 = external addrspace(1) global %Block4 | ||||||
| %gl_PV = type { <4 x i32>, i32, [1 x i32], [1 x i32] } | ||||||
| @pv1 = external addrspace(1) global %gl_PV | ||||||
|
|
||||||
| ; This should should not crash on variable offset that can be | ||||||
| ; optimized out (variable foo4 in the test) | ||||||
| define amdgpu_vs void @promote_load_from_store_aggr_varoff() local_unnamed_addr { | ||||||
|
||||||
| define amdgpu_vs void @promote_load_from_store_aggr_varoff() local_unnamed_addr { | |
| define amdgpu_vs void @promote_load_from_store_aggr_varoff() { |
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.
Sure
Outdated
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.
give a better name to indicate this is the interesting value
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.
Sure
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.
This looks like you're pre-filtering for a scenario that could happen in the map lookup. You should directly detect when this delete happens rather than assuming the set of cases it could
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 will make the code future proof. Will make the change
Uh oh!
There was an error while loading. Please reload this page.
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.
The deletion of this instuction happens after the transformation is done.
In the attached lit test, the dangling use of instruction in cached Index is result of replaceAllUsesWith() in promoteAllocaUserToVector() . Please advise. I will make this code generic (not for a specific scenario).
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.
One possible solution is to track these values with WeakVH. Then you'll just have to check if the value was already deleted before deleting it. This appears to be how SROA handles it, (see how DeadInsts is a vector of WeakVH)
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.
Thanks Matt. I will look in to weakVH
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.
WeakVH might not be useful here as the Value still exists in the code. We can do a DCE but I am not sure if it guaranteed if the Value has no uses in the code.
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.
You can easily check if the operation is dead. This pass is essentially doing the same thing as SROA, which checks isInstructionTriviallyDead