Skip to content

6.0: [MoveOnlyAddressChecker] Exclusivity handles DeadEnds. #75408

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

nate-chandler
Copy link
Contributor

@nate-chandler nate-chandler commented Jul 22, 2024

Explanation: Handle incomplete access scopes when diagnosing exclusivity issues.

The move-only address checker diagnoses exclusivity violations by checking whether consuming uses occur within an access scope (marked by one begin_access instruction and some number of end_access instructions). Specifically, it checks whether instructions that consume a value occur within the scope. If they do not, it emits an error.

In dead-end regions of a function (those from which there are no function exiting paths), special care must be taken when determining whether an instruction is live when the value which defines the region does not have a "complete lifetime" (a consuming use on every path). Access scopes do not always have complete lifetimes, so they need this special care. To get this special care, an instance of DeadEndBlocks must be passed to PrunedLiveness. (At the moment, it is also necessary to call areUsesWithinBoundary instead of isWithinBoundary, but that is only temporary.)

Here, the DeadEndBlocks instance is threaded a bit farther into the checker so that it can be passed along to PrunedLiveness.

The result is that consumes in dead-end blocks are correctly understood to be within the access scope when there is no end_access in that dead-end region.
Scope: Affects noncopyable code.
Issue: rdar://131960619
Original PR: #75404
Risk: Low. Amounts to passing an additional argument down in order to have an additional way to determine that an instruction is within a boundary. Furthermore, only affects the diagnostic relating to exclusivity emitted by the checker.
Testing: Added test.
Reviewer: Kavon Farvardin ( @kavon ), Joe Groff ( @jckarter )

Switch to the areUsesWithinBoundary API which takes dead-ends into
account.

rdar://131960619
@nate-chandler nate-chandler force-pushed the cherrypick/release/6.0/rdar131960619 branch from da03910 to 69b48ec Compare July 23, 2024 00:06
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@nate-chandler nate-chandler enabled auto-merge July 23, 2024 03:27
@ktoso
Copy link
Contributor

ktoso commented Jul 23, 2024

For tracking, this resolves #75312

@nate-chandler nate-chandler merged commit 7cbd1c1 into swiftlang:release/6.0 Jul 23, 2024
5 checks passed
@nate-chandler nate-chandler deleted the cherrypick/release/6.0/rdar131960619 branch July 23, 2024 13:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants