Skip to content

6.0: [SILGen] Store_borrow into in_guaranteed. #74209

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

nate-chandler
Copy link
Contributor

Explanation: Fix a move-checker diagnose-on-valid.

When generating reabstraction thunks, it may be necessary to convert a value to an address. This is done by creating a temporary allocation and somehow storing the value to it. Previously, if the value was @guaranteed, this always entailed creating a copy of the value and storing the copy. The copy was necessary because the store instruction consumes the value. This was a particular problem for non-copyable types: the move-checker doesn't currently promote copy_value + store to store_borrow. As a result the copy remained and was diagnosed.

Here, the extra copy is eliminated by using the store_borrow instruction instead which doesn't consume the stored value. This required teaching the move-checker not to insert destroys after last uses of guaranteed alloc_stacks (i.e. those which are store_borrow destinations).
Scope: Affects noncopyable code and reabstraction thunks.
Issue: rdar://128710064
Original PR: #74157
Risk: Low.
Testing: Added tests.
Reviewer: Joe Groff ( @jckarter )

If a marked location is used by `store_borrow`s, then all its users are
`store_borrow`s or `dealloc_stack`s, so there's nothing to destroy.
Don't create a copy in order to pass a value `@in_guaranteed`.  Just
`store_borrow` the value.

rdar://128710064
@nate-chandler nate-chandler requested a review from a team as a code owner June 7, 2024 14:12
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@nate-chandler nate-chandler requested a review from tbkka June 7, 2024 14:13
@nate-chandler nate-chandler enabled auto-merge June 7, 2024 16:14
@nate-chandler nate-chandler merged commit a65733c into swiftlang:release/6.0 Jun 7, 2024
5 checks passed
@nate-chandler nate-chandler deleted the cherrypick/release/6.0/rdar128710064 branch June 7, 2024 19:46
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