Skip to content

[6.0] SILGen: Emit references to noncopyable global storage directly as a borrow. #73056

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

jckarter
Copy link
Contributor

@jckarter jckarter commented Apr 16, 2024

Explanation: Fixes a bug where any access to a global or static property of "address-only" noncopyable type, such as Mutex or Atomic, would be diagnosed as a consume.
Scope: Bug fix.
Issue: rdar://114329759
Original PR: #73041
Risk: Low. The fix is targeted towards the affected case, which currently always raises a spurious error.
Testing: Swift CI
Reviewer: @atrick

…orrow.

Later analyses are too conservative to remove a copy, but it should be fairly safe to
elide the copy for noncopyable globals, since accesses are tightly scoped and dynamically checked,
so consumes aren't possible, and borrows and inout accesses of mutable globals are dynamically
guarded and not subject to exclusivity checks. rdar://114329759
@jckarter jckarter requested a review from a team as a code owner April 16, 2024 16:25
@jckarter
Copy link
Contributor Author

@swift-ci Please test

@jckarter jckarter changed the title SILGen: Emit references to noncopyable global storage directly as a borrow. [6.0] SILGen: Emit references to noncopyable global storage directly as a borrow. Apr 16, 2024
Copy link
Contributor

@atrick atrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jckarter jckarter merged commit f7ea907 into swiftlang:release/6.0 Apr 17, 2024
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