-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[MoveOnlyAddressChecker] Fix representation for reinit'd fields. #66945
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
@swift-ci please test |
@swift-ci please test macos platform |
if (bits.size() == 0) | ||
return; | ||
|
||
Optional<std::pair<unsigned, /*isSet*/ bool>> current = llvm::None; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be simpler to do:
Optional<unsigned> current = None
for ...
if (current) {
if (!isSet) {
callback
current = None
}
} else if (isSet) {
current = bit
}
}
if (current) { callback }
disclaimer, I didn't think hard about this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
fbf1561
to
eb4a25b
Compare
@swift-ci please test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Test case could use a comment but you don't need to restart CI just for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. In a subsequent PR just on main, can you add a swift test case as well?
Used the TypeTreeLeafTypeRange::setBits helper rather than looping over the range and setting the bits in place.
In preparation to share the getOrCreateConsumingBlock functionality with another overload of recordConsumingBlock.
The new overload iterates over the contiguous ranges in the bit vector and calls through to the overload that takes a range.
The address checker records instructions that reinit fields in its reinitInsts 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. (Indeed an attempt to add a second range that was reinit'd by an already reinit'ing instruction--even if it were overlapping or adjacent--would have no effect and the map wouldn't be updated.) Here, this is fixed by fixing the representation and updating the storage whenver a new range is seen to be reinit'd by the instruction. As in swiftlang#66728 , a SmallBitVector is the representation chosen. rdar://111356251
eb4a25b
to
4a5009a
Compare
Rebased and force-pushed in order to prefix the new use of Optional with |
@swift-ci please test and merge |
@swift-ci please smoke test macos platform |
The move-only address checker records instructions that reinit fields in its reinitInsts map. Previously, that map mapped from an instruction to a range of fields of the value. But an instruction can use multiple discontiguous fields of a single value. (Indeed an attempt to add a second range that was reinit'd by an already reinit'ing instruction--even if it were overlapping or adjacent--would have no effect and the map wouldn't be updated.) Here, this is fixed by fixing the representation and updating the storage whenver a new range is seen to be reinit'd by the instruction. As in #66728 , a SmallBitVector is the representation chosen.
rdar://111356251