6.0: [SILGen] Store_borrow into in_guaranteed. #74209
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 thestore
instruction consumes the value. This was a particular problem for non-copyable types: the move-checker doesn't currently promotecopy_value
+store
tostore_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 guaranteedalloc_stacks
(i.e. those which arestore_borrow
destinations).Scope: Affects noncopyable code and reabstraction thunks.
Issue: rdar://128710064
Original PR: #74157
Risk: Low.
Testing: Added tests.
Reviewer: Joe Groff ( @jckarter )