-
Notifications
You must be signed in to change notification settings - Fork 10.5k
5.9: [MoveOnlyAddressChecker] Fix representation for used fields. #66738
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 9 commits into
swiftlang:release/5.9
from
nate-chandler:cherrypick/release/5.9/rdar110676577_2
Jun 19, 2023
Merged
5.9: [MoveOnlyAddressChecker] Fix representation for used fields. #66738
nate-chandler
merged 9 commits into
swiftlang:release/5.9
from
nate-chandler:cherrypick/release/5.9/rdar110676577_2
Jun 19, 2023
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
According to language rules, such lifetimes are fixed and the relative order of their deinits is guaranteed. rdar://110913116
The members were declared but undefined.
Its storage vector is intended to be of some type like `std::vector<std::pair<Key, Optional<Value>>>`, i.e., some collection of pairs whose `second` is an `Optional<Value>`. So when constructing a default instance of that pair, just construct an Optional in the None case.
FieldSensitivePrunedLiveness is used as a vectorization of PrunedLiveness. An instance of FSPL with N elements needs to be able to represent the same states as N instances of PL. Previously, it failed to do that in two significant ways: (1) It attempted to save space for which elements were live by using a range. This failed to account for instructions which are users of non-contiguous fields of an aggregate. apply( @owned (struct_element_addr %s, #S.f1), @owned (struct_element_addr %s, #S.f3) ) (2) It used a single bit to represent whether the instruction was consuming. This failed to account for instructions which consumed some fields and borrowed others. apply( @owned (struct_element_addr %s, #S.f1), @guaranteed (struct_element_addr %s, #S.f2) ) The fix for (1) is to use a bit vector to represent which elements are used by the instruction. The fix for (2) is to use a second bit vector to represent which elements are _consumed_ by the instruction. Adapted the move-checker to use the new representation. rdar://110909290
Dumped more info and called llvm_unreachable on bad state.
Previously, the checker inserted destroys after each last use. Here, extend the lifetimes of fields as far as possible within their original (unchecked) limits. rdar://99681073
It's always the first line of the function, so try to do better.
Passing ``` -Xllvm -move-only-address-checker-disable-lifetime-extension=true ``` will skip the maximization of unconsumed field lifetimes.
90ab786
to
882ae97
Compare
The address checker records uses in its livenessUses map. Previously, that map mapped from an instruction to a range of fields of the type. But an instruction can use multiple discontiguous fields of a single value. Here, such instructions are properly recorded by fixing the map to store a bit vector for each instruction. rdar://110676577
882ae97
to
bff2838
Compare
@swift-ci please test |
tbkka
approved these changes
Jun 19, 2023
This was referenced Jun 27, 2023
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.
Description: Fix a class of miscompiles in the move-only address checker.
The move-only address checker records which instructions use ranges of fields of a move-only value. Previously, it recorded instructions with uses and the used fields via a map from instructions to ranges of fields of the value. But a single instruction can use non-gontiguous fields of the value being checked.
The fix is to change the the value stored corresponding to an instruction to have enough information to store all the non-contiguous fields of the value that it uses. Here, the representation of a bit vector is implemented.
Risk: Low. The change is involved, but the previous representation was wrong.
Scope: Narrow. This only affects move-only types.
Original PR: #66728
Reviewed By: Andrew Trick ( @atrick )
Testing: Added test that the move-only address checker previously miscompiled.
Resolves: rdar://110676577