-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Remove debug instructions on dead temporaries in CopyForwarding #32941
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
Conversation
|
I found this issue while doing the OSSA conversion for CopyForwarding. In OSSA MemoryLifetime verifier asserts on these debug_value_addr instructions on dead temp. |
atrick
left a comment
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 original code here is unnecessarily confusing because the comments talk about a "source" and "temp" address, but the users of the "temp" are captured in the member variables called SrcUserInsts and SrcDebugValueInsts (feel free to clarify that :)
I think it would be slightly more consistent to rely on the existing CopySrcUserVisitor, which is guaranteed to account for all the uses of the deleted temp. I believe it puts all the debug_value users in SrcDebugValueInsts.
The existing instruction scan already identifies all the user within the deleted scope:
if (SrcUserInsts.count(UserInst))
return nullptr;
It's just missing this check:
if (SrcDebugValueInsts.count(UserInst)) {
deletedDebugValues.push_back(UserInst);
continue;
}
|
@atrick Thanks, that is certainly more consistent. I have updated my changes. |
|
@swift-ci test |
|
Build failed |
|
Build failed |
atrick
left a comment
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!
|
Great catch! This is exactly the type of stuff to look for as we port! |
In CopyForwarding, we forward copy into a dead temp.
Example:
copy_addr %src to [init] %temp
copy_addr %temp [take] to %dest
becomes
copy_addr %src to %dest
Any debug_value_addr instructions on the dead temp between the source to temp copy and temp to dest copy refers to uninitialized memory. This PR deletes these debug_value_addr instructions.