[6.2][rbi] When checking for partial apply reachability of a value at a user, include the user itself in case the user is the actual partial apply #80903
+38
−6
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:
In RBI, we need to be more conservative around later uses of sent boxes that are also escaped by reference before the send point. To do this, we perform an earlier forward dataflow that determines partial applies that boxes escape to and then propagate reachability forward. Then when we send the box later, we mark the box as having already escaped at the sending point by using the reachability analysis. If the reachability analysis determines that the sending instruction is in a block where reachability starts, we walk the block to determine if the send is before or after the partial apply instruction. Sadly during this walk, we included all instructions up to the send instruction and not the send instruction itself. The result of this is that if the escaping partial apply and the send instruction were the same, we would say that the partial apply was not escaped and would say in cases like the following that the more conservative behavior did not need to be applied:
The result of this less conservative behavior is that we would think that no error needed to be emitted here since we would assume that
x
is never passed by reference so we do not need to consider concurrent writes tox
when we see the use ofx = 2
. Since no concurrent writes could occur to thex
box andx
contains aSendable
value, the box containingx
isSendable
in a flow sensitive manner at that point.Scope: Just tweaks a little bit of logic so that we include the partial apply "gen" instruction that we are searching for as the user that sends the value.
Resolves: rdar://149414471
Main PR: [rbi] When checking for partial apply reachability of a value at a user, include the user itself in case the user is the actual partial apply #80863
Risk: Low. This just tweaks an instruction walk slightly.
Testing: Added tests that show that the concurrency hole is eliminated.
Reviewer: @xedin