-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[6.0][region-isolation] Emit an error when we assign a non-disconnected value into a sending result. #75377
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
gottesmm
merged 8 commits into
swiftlang:release/6.0
from
gottesmm:release/6.0-rdar127318392
Jul 20, 2024
Merged
[6.0][region-isolation] Emit an error when we assign a non-disconnected value into a sending result. #75377
gottesmm
merged 8 commits into
swiftlang:release/6.0
from
gottesmm:release/6.0-rdar127318392
Jul 20, 2024
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
…require. TLDR: The reason why I am doing this is it ensures that temporary store_borrow that we create when materializing a value before were treated as uses. So we would error on this: ```swift @mainactor func transferToMain<T>(_ t: T) async {} func test() async { let x = NonSendableKlass() await transferToMain(x) await transferToMain(x) } ``` ---- store_borrow is an instruction intended to be used to initialize temporary alloc_stack with borrows. Since it is a temporary, we do not want to error on the temporaries initialization... instead, we want to error on the use of the temporary parameter. This is achieved by making it so that store_borrow still performs an assign/merge, but does not require that src/dest be alive. So the regions still merge (yielding diagnostics for later uses). It also required me to make it so that PartitionOp::{Assign,Merge} do not require by default. Instead, we want the individual operations to always emit a PartitionOp::Require explicitly (which they already did). One thing to be aware of is that when it comes to diagnostics, we already know how to find a temporaries original value and how to handle that. So this is the last part of making store_borrow behave nicely. rdar://129237675 (cherry-picked from commit bd472b1)
…s dead. (cherry picked from commit 3aee7da)
…e value is isolated to the same actor. rdar://132074953 (cherry picked from commit ebedf63)
…edIsolationInfo. Just slicing off a nice addition. These already had appropriate print methods so this commit just exposes the print API in the raw_ostream format. (cherry picked from commit 0b42f35)
…PartitionUtils.h and add APIs for mapping an ElementID -> Representative. This is just moving up the declaration in the chain of dependencies so that I can write logic in PartitionUtils.h using it. I also added entrypoints to lookup the ReprensetativeValue for our various emitters. (cherry picked from commit ace94b0)
… of just the representative of the source value when constructing assign and merge. This will let me know the exact source operand used instead of the source value representative. This will ensure that the name associated with the diagnostic is not of the representative value, but the actual value that was the source of the assign. This is an NFCI commit that is an algebraic refactor. (cherry picked from commit ae797d4)
…lue into a sending result. rdar://127318392 (cherry picked from commit bcbf5c5)
…dingResult() so that the unittests can override it. The unittests for PartitionUtils pass in mocked operands and instructions that cannot be dereferenced. Adding this static CRTP helper allows for the unittest PartitionOpEvaluator subclass to just return false for it instead of dereferencing operands or instructions. The rest of the evaluators just get to use the default "normal" implementation that actually accesses program state. (cherry picked from commit 1086264)
Other PR: #74495 |
@swift-ci test |
hborla
approved these changes
Jul 20, 2024
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.
NOTE: Other PR: #74495. All commits before caf944e are part of that other PR.
Explanation: This PR ensures that we can only assign disconnected values into sending results.
All commits except for 6649fac are basically refactoring commits that I split off to make them easy to eye ball by a reviewer that they are algebraic. Specifically:
Radars:
Original PRs:
Risk: Low. This is only adding an additional diagnostic. Additionally, the diagnostic can only be triggered if the value has a sending meaning that functions without sending results can never be affected by these changes. So we do get the additional diagnostics only in a very narrow case. Also most of the changes here are actually algebraic... the only one that really does anything interesting is 6649fac making it easier to review, lowering the risk even further
Reviewer: @hborla @ktoso