Skip to content

6.0: [PrunedLiveness] Branch summary merges to ending. #74836

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

nate-chandler
Copy link
Contributor

Explanation: Fix underlying utility and reinstate lifetime completion during move checking.

To address a compiler crash, move-checking's lifetime completion was partially disabled. Here, it is reenabled now that the compiler crash will no longer occur.

The move-only address checker depends on complete lifetimes; without them, it miscompiles code. So, if the checker determines that it will have to transform the function, it completes all (non-reborrow) lifetimes before transforming. That completion was temporarily partially disabled because it was producing invalid SIL. Here, the underlying issue which caused completion to produce invalid SIL is fixed and lifetime completion is reinstated to run as before.

The underlying issue was an incorrect summary calculation done by the PrunedLiveness utility. Specifically, it determined that branch instructions (e.g. br bbN(%x, %y)) were not lifetime-ending if they had both an owned value and a guaranteed value derived from that owned value as their operands. The result was ending lifetimes of the value actually consumed by the branch in the block that it branched to. This was invalid in a couple of ways: the value was overconsumed, the destroy might not dominate the def. In noasserts builds, this resulted in a compiler crash during LLVM.

Now that the underlying issue is fixed, lifetime completion doesn't produce invalid SIL, and the compiler doesn't crash during LLVM.

In OSSA, in the target block, the guaranteed block argument is understood to be derived from the owned block argument.
Scope: Affects noncopyable code.
Issue: rdar://130427564
Original PR: #74815 , #74835
Risk: Low.
Testing: Added and updated tests. Rebuilt project exhibiting compiler crash without fix.
Reviewer: Andrew Trick ( @atrick ), Meghana Gupta ( @meg-gupta )

A branch instruction that is both a lifetime-ending user and also a
non-lifetime-ending of a value should be regarded as a lifetime-ending
user.

Without this, utilities that rely on PrunedLiveness such as
`LinearLiveness` and `InteriorLiveness` both incorrectly report that a
branch featuring a value and also a reborrow or guaranteed phi are
non-ending.

rdar://130427564
Now that the underlying issue (PrunedLiveness' merging of summaries for
branch instructions) has been fixed, reinstate lifetime completion and
add a test to verify that it behaves correctly.

This reverts commit c552b90
("Temporarily turn off completing lifetimes of block arguments").

rdar://130427564
@nate-chandler nate-chandler requested a review from a team as a code owner June 28, 2024 22:28
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@nate-chandler nate-chandler enabled auto-merge June 28, 2024 22:53
@nate-chandler
Copy link
Contributor Author

@swift-ci please test linux platform

@nate-chandler nate-chandler merged commit 73a2819 into swiftlang:release/6.0 Jun 29, 2024
5 checks passed
@nate-chandler nate-chandler deleted the cherrypick/release/6.0/rdar130427564_2 branch June 29, 2024 13:59
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.

2 participants