5.9: [MoveOnlyAddressChecker] Fixed two use-before-def handlings. #66905
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 two classes of miscompiles in the move-only address checker.
Back in #65000, Andrew added support for addreses (by way of handling for uses before defs) to PrunedLiveness. Here, the unit tests that Andrew wrote to verify that support is ported to FieldSensitivePrunedLiveness.
One of those unit tests revealed a bug in FieldSensitivePrunedLiveness's handling of uses before defs. That issue resulted in miscompiles for simple Swift programs featuring move-only values and loops; see the new test
Interpreter/moveonly_loop.swift. Here, that is fixed by replacing FieldSensitivePrunedLiveness' own attempt to handle uses-before-defs with a copy of the implementation from PrunedLiveness and a straightforward vectorization.Finally, fixing that bug in FieldSensitivePrunedLiveness revealed a bug in the multi-def lifetime extension for move-only values stored in addresses. The important difference between the algorithm used by the address checker and the algorithm used by the value checker is that the former is multi-def and so must handle uses-before-defs. The discovery of consumed blocks was properly handling that case, but the discovery of original live blocks was not. Here, that is fixed by walking through already discovered blocks if those blocks do not kill liveness.
Risk: Low. The first fix straightforwardly vectorizes a copy of the scalar code that determines whether there's a use before a def. The second fix amounts to using a variation of the normal way to compute liveness.
Scope: Narrow. This only affects move-only types.
Original PR: #66892
Reviewed By: Andrew Trick ( @atrick )
Testing: Added test that the move-only address checker previously miscompiled.
Resolves: rdar://110862719&111118843&111221183