-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[OSSACanonicalizeOwned] Dead-end extend base lifetime. #79521
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
db84a47
to
4642e30
Compare
@swift-ci build toolchain |
c3743bb
to
8ff107f
Compare
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.
Here are my review notes. Maybe they are useful for comments...
- lexical-scope-extended liveness (lexical vars only):
1a. Separately compute the lexical lifetime of the original def.
This cannot include any consumes of copies. Otherwise, we would fail to extend the original lexical def:
%copy = copy_value %def
consume %copy
apply foo()
// need to extend the liveness of %def up to this point.
unreachable
Note that none of the copied values are lexical, so they don't need to be extended to dead-end blocks.
1b. visit the lexical lifetime's availability boundary
Add the lexical boundary as uses to the current copy-extended liveness
Now we have an adjusted liveness that considers both the lexical lifetime and the copy-extended lifetime
===
2. complete liveness (always needed)
2a. create a temporary copy of copy-extended liveness
2b. demote and consumes within temporary liveness
If a lifetime-ending use is not on the liveness boundary, consider it a non-lifetime-ending use
Required by visitAvailabilityBoundary--the interior consumes will always be copied so they never kill availability.
2c. call visitAvailabilityBoundary on temporary liveness
Add instructions on the availability boundary to the original liveness, thereby extending it
Required to avoid inserting destroys within a borrow scope
%c = copy_value %def
%sb = store_borrow %c to ...
// destroy_value %def - invalid
unreachable
8ff107f
to
853fdc1
Compare
@swift-ci please test |
@swift-ci please apple silicon benchmark |
@swift-ci please test source compatibility |
@swift-ci please build toolchain |
@swift-ci please test macos platform |
1 similar comment
@swift-ci please test macos platform |
Uses of borrows may occur between the borrow and a dead-end regardless of lexicality, so always extend lifetimes to dead-ends.
Regardless of consumes of copies, if the original lexical value is not consumed on a dead-end path, it must remain live to that dead-end. rdar://145226757
If there is a pointer escape, we cannot safely rewrite its lifetime.
853fdc1
to
8e7dae5
Compare
@swift-ci please test |
Regardless of consumes of copies, if the original lexical value is not consumed on a dead-end path, it must remain live to that dead-end.
rdar://145226757