Skip to content

[MoveChecker] Distinguished scope end diagnostics. #71162

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

There are several kinds of scopes at which it is required that an address be initialized:
(1) the whole function -- for inout argument to the function
(2) the region a coroutine is active -- for an inout yielded by a coroutine into the function
(3) the region of a memory access -- for a begin_access [modify].

The move checker enforces that they are initialized at that point by adding instructions at which the field must be live to liveness.

Previously, all such scopes used the end of the function as the point at which the memory had to have been reinitialized. Here, the relevant end of scope markers are used instead.

More importantly, here the diagnostic is made to vary--the diagnostic, that is, that is issued in the face an address not being initialized at the end of these different kind of scopes.

@nate-chandler
Copy link
Contributor Author

@swift-ci please test

The version for Value and Instruction are identical except for the type
of the source of the cast to SILNode.  Add an overload for SILNode
through which the other two call.
Whether a node is a def on a collection of bits (whether a range or a
bit vector) isn't exhaustively characterized by the values {true,
false}.  A node may be a def on some but not others of the bits in the
collection.  Changed the range-taking isDef to write back the bits in
the range at which the node is a def.  The caller can then decide how to
react with full information.
Add a new SILNode taking overload and change the SILInstruction and
SILValue taking overloads to call it.
Simplified diagnostic emission to use a single code path.
There are several kinds of scopes at which it is required that an
address be initialized:
(1) the whole function -- for inout argument to the function
(2) the region a coroutine is active -- for an inout yielded by a
    coroutine into the function
(3) the region of a memory access -- for a `begin_access [modify]`.

The move checker enforces that they are initialized at that point by
adding instructions at which the field must be live to liveness.

Previously, all such scopes used the end of the function as the point at
which the memory had to have been reinitialized.  Here, the relevant end
of scope markers are used instead.

More importantly, here the diagnostic is made to vary--the diagnostic,
that is, that is issued in the face an address not being initialized at
the end of these different kind of scopes.
Use the same code path to add users at which an address must have been
reinitialized for both kinds of mark_unresolved_non_copyable_value which
permit assignment.
When extending liveness, the instructions prior to a preexisting destroy
are added to liveness.  If that prior instruction is the def, adding it
to liveness results in multi-def liveness understanding that there is a
prior def.

Fixes a bug exposed by adding coroutine ends to liveness rather than
function ends.
@nate-chandler nate-chandler force-pushed the partial-consumption/20240125/1/scope-end-diagnostic branch from ab9dafd to bff7618 Compare January 29, 2024 20:32
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

@nate-chandler
Copy link
Contributor Author

@swift-ci please test source compatibility

@nate-chandler nate-chandler marked this pull request as ready for review January 30, 2024 02:27
@nate-chandler nate-chandler merged commit f2d68a2 into swiftlang:main Jan 30, 2024
@nate-chandler nate-chandler deleted the partial-consumption/20240125/1/scope-end-diagnostic branch January 30, 2024 02:27
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.

1 participant