-
Notifications
You must be signed in to change notification settings - Fork 10.5k
6.0: [MoveOnlyAddressChecker] Fix empty deiniting struct representation. #73178
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
nate-chandler
merged 1 commit into
swiftlang:release/6.0
from
nate-chandler:cherrypick/release/6.0/rdar126863003
Apr 22, 2024
Merged
6.0: [MoveOnlyAddressChecker] Fix empty deiniting struct representation. #73178
nate-chandler
merged 1 commit into
swiftlang:release/6.0
from
nate-chandler:cherrypick/release/6.0/rdar126863003
Apr 22, 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
@swift-ci please test |
kavon
approved these changes
Apr 22, 2024
tbkka
approved these changes
Apr 22, 2024
An empty struct without a deinit gets a single bit which is used to track the struct's liveness. Previously, an empty struct with a deinit also only got a single bit. Consequently, when discarding the struct (i.e. dropping the deinit), there was no bit left to represent the struct. This resulted in a failure to track liveness for the value. rdar://126863003
65ab9eb
to
74a2c76
Compare
@swift-ci please test |
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.
Explanation: Fix MoveOnlyAddressChecker miscompile caused by not representing empty struct with deinit.
The checker represents each type as a bitfield. An empty struct without a deinit gets a single bit--that bit corresponds to the whole struct. That allows the checker to track uses of the whole struct as a use of some bit.
Previously, the checker only represented an empty struct with a deinit as a single bit too. The single bit in this case corresponds to the deinit. When the deinit is dropped via discard, there is still an empty struct whose lifetime needs representation in bits--it should have the same number of bits as an empty struct without a deinit--i.e. two.
Here, the problem is fixed by giving an empty struct with a deinit two bits.
Scope: Affects noncopyable code.
Issue: rdar://126863003
Original PR: #73174
Risk: Low.
Testing: Added and updated unit tests.
Reviewer: @kavon