Skip to content

[SILGenCleanup] Complete lifetimes of defs backwards reachable from dead-end blocks. #78105

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
merged 11 commits into from
Dec 19, 2024

Conversation

nate-chandler
Copy link
Contributor

@nate-chandler nate-chandler commented Dec 11, 2024

For a function to have complete lifetimes, the lifetime of every def in the function which is backwards-reachable from a dead-end block must be completed.

Previously, every def in every block which appears in the post-order of the function's blocks is completed. This was not enough: defs in "unreachable blocks" (i.e. those which aren't forwards-reachable from the function entry) must be completed too, and such blocks do not appear in the function's post-order.

Here, defs in unreachable blocks are be completed too. Such defs must also be completed in relative post-order. To do this, roots for the non-entry post-orders must be found.

rdar://141197164

@nate-chandler nate-chandler force-pushed the rdar141197164 branch 3 times, most recently from 37aaee9 to 15e5a26 Compare December 16, 2024 15:09
@nate-chandler nate-chandler marked this pull request as ready for review December 16, 2024 19:22
@nate-chandler nate-chandler removed the request for review from jckarter December 16, 2024 19:22
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@nate-chandler
Copy link
Contributor Author

@swift-ci please apple silicon benchmark

@nate-chandler
Copy link
Contributor Author

@swift-ci please test source compatibility

@nate-chandler nate-chandler changed the title [SILGenCleanup] Complete lifetimes of defs backwards reachable from unreachable instructions. [SILGenCleanup] Complete lifetimes of defs backwards reachable from dead-end blocks. Dec 17, 2024
Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

Nice!
Just some minor comments.

@nate-chandler nate-chandler force-pushed the rdar141197164 branch 3 times, most recently from 2fa5ce2 to 8fd1780 Compare December 18, 2024 17:26
Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

lgtm!

Add a helper similar to findExitingBlocks.
In preparation for adding more users.
It was previously `isVisited`.  And mark `visit` private, it needn't be
part of the interface for any current clients.
Don't form a set of unreachable blocks, we only need to check whether
any given block is unreachable, which can be done via
`ReachableBlocks::isVisited`.
The method walks over the blocks of the function testing each for
reachability and returns false on the first that is not.
In preparation for completing lifetimes in multiple ranges (namely
post-orders of subgraphs of the function), extract a complete-in-range
method.
Enable clients to check whether the worklist has anything in it without
popping a block to find out.
For a function to have complete lifetimes, the lifetime of every def in
the function which is backwards-reachable from a dead-end block must be
completed.

Previously, every def in every block which appears in the post-order of
the function's blocks is completed.  This was not enough: defs in
"unreachable blocks" (i.e. those which aren't forwards-reachable from
the function entry) must be completed too, and such blocks do not appear
in the function's post-order.

Here, defs in unreachable blocks are be completed too.  Such defs must
also be completed in relative post-order.  To do this, roots for the
non-entry post-orders must be found.

rdar://141197164
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@nate-chandler
Copy link
Contributor Author

@swift-ci please apple silicon benchmark

@nate-chandler
Copy link
Contributor Author

@swift-ci please test source compatibility

@nate-chandler
Copy link
Contributor Author

@swift-ci please test linux platform

@nate-chandler nate-chandler merged commit 419d87d into swiftlang:main Dec 19, 2024
7 of 8 checks passed
@nate-chandler nate-chandler deleted the rdar141197164 branch December 19, 2024 04:28
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