Skip to content

[BarrierAccessScopes] Handle end_access instructions' barrierness introduced during run. #77908

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 6 commits into from
Dec 4, 2024

Conversation

nate-chandler
Copy link
Contributor

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

As the utility runs, new gens may become local: as access scopes are determined to contain deinit barriers, their end_access instructions become kills; if such an end_access occurs in the same block above an initially-non-local gen, that gen is now local.

Previously, it was asserted that kills would not be encountered when visiting a block backwards from an initially-non-local gen. As described above, the assertion was incorrect.

Iteration would also stop at the discovered kill, if any. That too was incorrect. To continue walking the block after finding such a newly discovered kill is needed by the book-keeping the utility does for which access scopes contain barriers: there may be more end_access instructions. Concretely, there are two cases: (1) The block may contain another end_access and above it a deinit barrier which must result in that second scope becoming a deinit barrier. (2) Some of the block's predecessors may be in the region, all the access scope which are open at the begin of this block must be unioned into the set of scopes open at each predecessors' end, and more such access scopes may be discovered above the just-visited end_access.

Here, both the assertion failure and the early bailout are fixed by walking from the indicated initially-non-local gen backwards over the entire block, regardless of whether a kill was encountered. If a kill is encountered, it is asserted that the kill is an end_access to account for the case described above.

rdar://139840307

As the utility runs, new gens may become local: as access scopes are
determined to contain deinit barriers, their `end_access` instructions
become kills; if such an `end_access` occurs in the same block above an
initially-non-local gen, that gen is now local.

Previously, it was asserted that initially-non-local gens would not
encounter when visiting the block backwards from that gen.  Iteration
would also _stop_ at the discovered kill, if any.  As described above,
the assertion was incorrect.

Stopping at the discovered kill was also incorrect.  It's necessary to
continue walking the block after finding such a new kill because the
book-keeping the utility does for which access scopes contain barriers.
Concretely, there are two cases:
(1) It may contain another `end_access` and above it a deinit barrier
which must result in that second scope becoming a deinit barrier.
(2) Some of its predecessors may be in the region, all the access scopes
which are open at the begin of this block must be unioned into the set
of scopes open at each predecessors' end, and more such access scopes
may be discovered above the just-visited `end_access`.

Here, both the assertion failure and the early bailout are fixed by
walking from the indicated initially-non-local gen backwards over the
entire block, regardless of whether a kill was encountered.  If a kill
is encountered, it is asserted that the kill is an `end_access` to
account for the case described above.

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

@swift-ci please test

@nate-chandler
Copy link
Contributor Author

@swift-ci please test source compatibility

@nate-chandler
Copy link
Contributor Author

@swift-ci please apple silicon benchmark

@nate-chandler
Copy link
Contributor Author

@swift-ci please test macos platform

@nate-chandler
Copy link
Contributor Author

@swift-ci please test linux platform

@nate-chandler nate-chandler marked this pull request as ready for review December 3, 2024 23:15
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.

Makes sense!

@nate-chandler nate-chandler merged commit 0d76250 into swiftlang:main Dec 4, 2024
8 checks passed
@nate-chandler nate-chandler deleted the rdar139840307 branch December 4, 2024 23:29
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