Skip to content

[move-only] A few small changes in preparation for a larger patch #63755

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

Conversation

gottesmm
Copy link
Contributor

This PR contains a few small helper PRs and also enables by default a diagnostic error that is emitted if the checkers missed a copy. The diagnostic asks the user to file a bug. This is better than crashing the compiler.

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

@xedin xedin removed their request for review February 17, 2023 21:17
I am using this query a lot in SILGen when adding support for escaping
captures. Makes sense to chop it off into a nice little helper on SILType.
…a SILBoxType from the SILType field for you.
Just treating it the same as copy_addr as expected.
This works by emitting an object level copy_addr if an address type is
loadable (that is using load [take] + store [init] instead of copy_addr).
…sform.

Specifically, our operand /could/ be a SILArgument. In that case, oldInst in all
of these cases will be a nullptr. So make sure to only delete them if we
actually found a defining instruction.
…ship specifier.

Otherwise, we cannot parse our own compiler output around guaranteed boxes. I
discovered this when writing tests for the next commit.

rdar://105635396
…pe, move mark_must_check onto alloc_stack and always

ensure that we use consumable_to_assign.

What this patch is does is add an extra phase after alloc_box runs where we look
at uses of the alloc_stack and if we see any mark_must_check of any kind, we
delete them and rewrite a single mark_must_check [consumable_and_assignable] on
the alloc_stack and make all uses of the alloc_stack go through the
mark_must_check.

This has two effects:

1. In a subsequent PR when I add noncopyable semantics for escaping closures,
this will cause allocbox to stack to convert such boxes from having escaping
semantics to having non-escaping semantics. Escaping semantics means that we
always reproject out from the box and use mark_must_check
[assignable_but_not_consumable] (since we can't consume from the box, but can
assign to it). In contrast, non-escaping semantics means that the box becomes an
alloc_stack and we use the traditional var checker semantics. NOTE: We can do
this for lets represented as addresses and vars since the typechecker will
validate that the let is never actually written to even if at the SIL level we
would allow that.

2. In cases where we are implementing simple mark_must_check
[consumable_and_assignable] on one of the project_box and capture the box, we
used to have a problem where the direct box uses would be on the alloc_stack and
not go through the mark_must_check. Now, all uses after allocbox_to_stack occur
go through the mark_must_check. This is why I was able to remove instances of
the "compiler does not understand this pattern" errors... since the compiler
with this change can now understand them.
@gottesmm gottesmm force-pushed the pr-dac78af5673ab6d4a9bebea882b8440c37c9457c branch from 430c7ab to 969d776 Compare February 18, 2023 21:15
@gottesmm
Copy link
Contributor Author

Put some more small changes in here cutting off from a larger change.

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

@gottesmm gottesmm merged commit ecb864c into swiftlang:main Feb 19, 2023
@gottesmm gottesmm deleted the pr-dac78af5673ab6d4a9bebea882b8440c37c9457c branch February 19, 2023 01:03
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