-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[SIL] Represent copies to @sil_unowned values. #67722
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
nate-chandler
merged 10 commits into
swiftlang:main
from
nate-chandler:opaque-values/1/20230803/unowned-copies
Aug 9, 2023
Merged
[SIL] Represent copies to @sil_unowned values. #67722
nate-chandler
merged 10 commits into
swiftlang:main
from
nate-chandler:opaque-values/1/20230803/unowned-copies
Aug 9, 2023
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b00ccb1
to
7477911
Compare
The new instruction unwraps an `@sil_weak` box and produces an owned value. It is only legal in opaque values mode and is transformed by `AddressLowering` to `load_weak`.
The new instruction wraps a value in a `@sil_weak` box and produces an owned value. It is only legal in opaque values mode and is transformed by `AddressLowering` to `store_weak`.
Lower the `strong_copy_weak_value` and `weak_copy_value` to `load_weak` and `store_weak` respectively.
In opaque values mode, emit the new weak copy instructions to convert as follows: strong_copy_weak_value: `@owned $sil_weak T?` -> `@owned $T?` weak_copy_value: `@owned $T?` -> `@owned $@sil_weak T?` Doing so is necessary in opaque values mode where it is needed to deal with weak values directly rather than indirectly via `load_weak`s and `store_weak`s.
The ref_to_* and *_to_ref instructions must not produce or take as their operands values of address-only type. The AddressLowering pass would trap on encountering such illegal instructions already. Enforce the invariant in the verifier.
Lower the `strong_copy_unowned_value` and `unowned_copy_value` to `load_unowned` and `store_unowned` respectively.
In opaque values mode, emit the unowned copy instructions to convert as follows: strong_copy_unowned_value: `@owned $sil_unowned T` -> `@owned $T` unowned_copy_value: `@owned T` -> `@owned $sil_unowned T` Doing so is necessary in opaque values mode where it is needed to deal with unowned values directly rather than indirectly via `load_unowned`s and `store_unowned`s.
7477911
to
ded4d32
Compare
atrick
approved these changes
Aug 8, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks all the reference types have been covered!
@swift-ci please test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Based on #67690 . Adds four commits.
Introduce the instructions
unowned_copy_value
. The effect ofunowned_copy_value %o : $T
is to increment the unowned reference count of the instance%o
of the reference typeT
.AddressLowering transforms as follows:
strong_copy_unowned_value
->load_unowned
unowned_copy_value
->store_unowned