Skip to content

Conversation

@meg-gupta
Copy link
Contributor

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.

@meg-gupta
Copy link
Contributor Author

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.

@meg-gupta meg-gupta requested review from atrick and gottesmm July 17, 2020 02:17
Copy link
Contributor

@atrick atrick left a 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;
    }

@meg-gupta meg-gupta changed the title In CopyForwarding, remove debug instructions on dead temporaries Remove debug instructions on dead temporaries in CopyForwarding Jul 17, 2020
@meg-gupta
Copy link
Contributor Author

@atrick Thanks, that is certainly more consistent. I have updated my changes.

@meg-gupta
Copy link
Contributor Author

@swift-ci test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - f05262855033115ab4d4ffdb201b60bb00a36136

@swift-ci
Copy link
Contributor

Build failed
Swift Test OS X Platform
Git Sha - f05262855033115ab4d4ffdb201b60bb00a36136

Copy link
Contributor

@atrick atrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@meg-gupta meg-gupta merged commit 858fe6c into swiftlang:master Jul 22, 2020
@gottesmm
Copy link
Contributor

Great catch! This is exactly the type of stuff to look for as we port!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants