-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[region-isolation] Fix actor region propagation and some other smaller issues. #69387
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
…n actor and treat its region as being within an actor's isolation domain. Importantly, we determine at the error stage if a specific value that is transferred is within the same region of a value that is Actor derived. This means that we can in a flow insensitive manner determine the values that are actor derived and then via propagating those values into various regions determine the issue... using our region analysis to handle the flow sensitivity. One important case to reason about here is that since we are relying on the region propagation for flow sensitivity is that this solves the var case for us. A var when declared is never marked as actor derived. Var uses only become actor derived if the var was merged into a region that contain is actor derived. That means that re-assigning to a non-actor derived value, eliminates the actor derived bit. As part of this, I also discovered I could just get rid of the captured uniquely identified array in favor of just passing in an actor derived flag. rdar://115656589
…ress in a partial_apply rather than if we send it to any function apply. Semantically these are the only cases where we would want to force an address to be merged. Some notes: 1. When we have a box, the project_box is considered to come from the box and is considered non uniquely identified. 2. The only place this was really triggering was when we created temporary partial applies to pass to a function when using address only types. Since this temporaries are never reassigned to, there isn't any reason to require them to be merged. 3. In the case where we have an alloc_stack grabbed by a partial_apply, we still appropriately merge.
…s, just cache the function entry partition. We only ever used this cache of IDs to construct the function arg partition. Since a Partition involves using memory, it makes sense to just cache the Partition itself and eliminate the unnecessary second cache.
…reat it like an assignment. If we treat a begin_access as an assignment then in cases like below we assume that a value was used before we reassign. ``` func testVarReassignStopActorDerived() async { var closure = {} await transferToMain(closure) // This re-assignment shouldn't error. closure = {} // (1) } ``` rdar://117437299
…t all blocks during the dataflow... just do the translation when we initialize block state. We are going to visit all of the blocks anyways... so it makes sense to just run them as part of the initializing of the block state. Otherwise, the logic is buried in the dataflow which makes it harder for someone who is not familiar with the pass to reason about it.
…that they are derived from. Otherwise, it is hard to tell what one is looking at when looking at the pseudo-ir.
@swift-ci smoke test |
return translateSILAssign(inst->getResult(0), inst->getOperand(0)); | ||
} | ||
|
||
case SILInstructionKind::EnumInst: { |
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.
Is this case new? Does it have a test?
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.
Yes. It came up with the enum test cases I added below. I wish we had SIL test cases which would make it easier to understand the connection.
@@ -339,7 +339,7 @@ class PartitionOpTranslator { | |||
std::vector<TrackableValueID> neverTransferredValueIDs; | |||
|
|||
/// A cache of argument IDs. | |||
SmallVector<TrackableValueID> argIDs; | |||
std::optional<Partition> functionArgPartition; |
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.
Maybe make it mutable?
This PR contains a few different changes:
That being said, I found a few bugs in the process that I filed radars for that I will fix in subsequent PRs. I added tests for all of them into this PR with TODOs.