Skip to content

6.0: [MoveOnlyAddressChecker] Fix representation for consumed fields. #72497

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 Mar 21, 2024

Explanation: Fix a class of overconsumes by teaching the move-only address checker that an instruction can consume multiple fields.

An instruction can consume multiple fields of an aggregate which is being checked. For example, apply %fn(%field1, %field3). Where %field1 and %field3 are noncontiguous fields of some struct.

Previously, for a single instruction, the checker only tracked a single contiguous range of bits which the instruction consumed. It couldn't represent instructions such as this apply. Consequently, it failed to recognize that fields of the aggregate beyond the first it examined were consumed by the instruction. The result was an overconsume of each field beyond the first.

Here, this is fixed by associating a vector of bits with each instruction.
Scope: Affects move-only checking.
Issue: rdar://125103951
Original PR: #72463
Risk: Low.
Testing: Added test case that was previously miscompiled.
Reviewer: Joe Groff ( @jckarter )

The function is long and will get longer.
The name `livenessUses` doesn't readily communicate the fact that those
uses are all non-consuming.
Previously, whenever an instruction was recorded as a final consume, a
new entry was added to finalBlockConsumes.  Here, this is changed to add
the new bits being consumed by the instruction to the preexisting
SmallBitVector, if there is one.
An instruction can consume multiple (discontiguous) fields.  Use a
SmallBitVector to track the fields consumed by an instruction rather
than a TypeTreeLeafRange.

rdar://125103951
@nate-chandler nate-chandler requested a review from a team as a code owner March 21, 2024 20:02
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@nate-chandler nate-chandler merged commit a8b01bf into swiftlang:release/6.0 Mar 22, 2024
@nate-chandler nate-chandler deleted the cherrypick/release/6.0/rdar125103951 branch March 22, 2024 01:29
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.

2 participants