Skip to content

[Mem2Reg] Fix store_borrow user block omission. #64834

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

nate-chandler
Copy link
Contributor

Previously, when blocks were added to the worklist, only blocks which were users of the alloc_stack instruction were considered. For "guaranteed alloc_stacks" (store_borrow locations), that resulted in not processing blocks which contained uses of the store_borrow but not the alloc_stack. When such a user was an end_borrow, the effect was that no end_borrow was created for the newly introduced begin_borrow [lexical].

Fix this by adding blocks with users of the store_borrow to the worklist.

Previously, when blocks were added to the worklist, only blocks which
were users of the `alloc_stack` instruction were considered.  For
"guaranteed alloc_stacks" (`store_borrow` locations), that resulted in
not processing blocks which contained uses of the `store_borrow` but not
the `alloc_stack`.  When such a user was an `end_borrow`, the effect was
that no `end_borrow` was created for the newly introduced
`begin_borrow [lexical]`.

Fix this by adding blocks with users of the `store_borrow` to the
worklist.
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@nate-chandler
Copy link
Contributor Author

@swift-ci please test macos platform

1 similar comment
@nate-chandler
Copy link
Contributor Author

@swift-ci please test macos platform

@meg-gupta
Copy link
Contributor

@nate-chandler Do we need a similar change for load_borrows as well ?

@nate-chandler
Copy link
Contributor Author

No, for the same reason that we don't need to visit all uses of regular loads. Uses of a load_borrow(or load) are all replaced when the load_borrow is visited. On the other hand, a store_borrow can be thought of as introducing a new name for the alloc_stack which was stored to; that's why they must be added to the list of blocks to process separately.

Copy link
Contributor

@meg-gupta meg-gupta left a comment

Choose a reason for hiding this comment

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

LGTM

@nate-chandler nate-chandler merged commit 756fe15 into swiftlang:main Apr 3, 2023
@nate-chandler nate-chandler deleted the mem2reg-store_borrow-users branch April 3, 2023 18:53
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