-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[CanonicalizeOSSALifetime] Extend lexical lifetimes to unreachables. #68608
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
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e09b267
to
49b9acd
Compare
@swift-ci please test |
atrick
approved these changes
Sep 20, 2023
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.
Looks good!
It was already addressed.
It's useful to be able to form a second copy of liveness which is differently pruned by having more instructions added to it, e.g..
Don't respect deinit barriers when canonicalizing if lexical lifetimes are disabled.
Extracted the new visitUnreachableLifetimeEnds static member of OSSALifetimeCompletion from the preexisting endLifetimeAtUnreachableBlocks which now calls through the former.
49b9acd
to
a1695bc
Compare
@swift-ci please test |
When canonicalizing the lifetime of a lexical value, deinit barriers are respected. This is done by walking backwards from lifetime ends and adding encountered deinit barriers to liveness. Only destroy lifetime ends were walked back from under the assumption that lifetimes would be complete. Without complete OSSA lifetimes, however, it's necessary to also necessary to consider lifetimes that end with unreachables. Unfortunately, we can't simply walk back from those unreachables because there may be instructions which are secretly users of the value being canonicalized (e.g. destroys of `partial_apply`s to which a `begin_borrow` of the value was passed). Such uses don't appear in the use list because lifetime canonicalization expects complete lifetimes and only visits lifetime ends of `begin_borrow`s. Here, instead, the instructions before the relevant unreachables are added to liveness. In order to determine which unreachables are relevant, it's necessary to have a liveness that includes the original destroys. So a copy of liveness is created and those destroys are added to it. rdar://115468707
Such destroys are part of the lifetime of lexical values inserted to prevent shortening lifetimes over deinit baarriers by CanonicalizeOSSALifetime. After OSSALifetimeCompletion is enabled, more instructions will need to be preserved.
a1695bc
to
b902ad7
Compare
@swift-ci please test |
@swift-ci please benchmark |
@swift-ci please test source compatibility |
@swift-ci please apple silicon benchmark |
@swift-ci please test windows platform |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When canonicalizing the lifetime of a lexical value, deinit barriers are respected. This is done by walking backwards from lifetime ends and adding encountered deinit barriers to liveness.
Only destroy lifetime ends were walked back from under the assumption that lifetimes would be complete. Without complete OSSA lifetimes, however, it's necessary to also necessary to consider lifetimes that end with unreachables. Unfortunately, we can't simply walk back from those unreachables because there may be instructions which are secretly users of the value being canonicalized (e.g. destroys of
partial_apply
s to which abegin_borrow
of the value was passed). Such uses don't appear in the use list because lifetime canonicalization expects complete lifetimes and only visits lifetime ends ofbegin_borrow
s.Here, instead, the instructions before the relevant unreachables are added to liveness. In order to determine which unreachables are relevant, it's necessary to have a liveness that includes the original destroys. So a copy of liveness is created and those destroys are added to it.
rdar://115468707