Skip to content

[move-only] A group of batched changes #65353

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

  1. First change converts __shared -> borrowed in the tests. I did this since semantically there isn't a difference beyond mangling and it makes sense to match what our users will use.
  2. I turned off emitting move only errors on functions if we already emitted an escaping capture bug for that function. The reason why is because SILGen today assumes that we will error in such cases and thus does not emit markers in said function for the inout. This then causes us to emit spurious "found a copy of a noncopyable value" errors that
    may cause the user to think there is a bug in the compiler.

@gottesmm gottesmm requested a review from kavon April 21, 2023 16:57
@gottesmm
Copy link
Contributor Author

@swift-ci test

@gottesmm
Copy link
Contributor Author

In a forthcoming commit, the 2nd commit will come into play, I am just peeling the onion

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

@gottesmm gottesmm force-pushed the pr-7fddccd1df47d4c57c27121727562d691b9f2397 branch from eb19ee7 to 0ac6fac Compare April 24, 2023 17:41
@gottesmm
Copy link
Contributor Author

@swift-ci test

@kavon kavon requested a review from atrick April 24, 2023 18:10
@gottesmm
Copy link
Contributor Author

@swift-ci test source compatibility

@gottesmm gottesmm force-pushed the pr-7fddccd1df47d4c57c27121727562d691b9f2397 branch from 0ac6fac to 1f1f250 Compare April 24, 2023 19:14
@gottesmm
Copy link
Contributor Author

@swift-ci test

@gottesmm
Copy link
Contributor Author

@swift-ci test source compatibility

Copy link
Contributor

@atrick atrick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only reviewed the commit "[move-only] Instead of using AccessUseVisitor to visit addresses"

Looks good. Just a few comments inline.

Ideally the starting address producers would be in sync with AccessUseDefChainVisitor<Impl, Result>::visit. We're just missing a few of the unusual cases.

@atrick atrick self-requested a review April 24, 2023 20:00
Copy link
Member

@kavon kavon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks fine overall. Just some API suggestions and questions.

…lization that makes it easy to look for errors around specialization.
@xedin xedin removed their request for review April 25, 2023 17:21
@gottesmm gottesmm force-pushed the pr-7fddccd1df47d4c57c27121727562d691b9f2397 branch from 1f1f250 to 02c0ebd Compare April 25, 2023 17:49
…TransitiveAddressVisitor.

This makes it so that the move address checker is not dependent on starting the
traversal at a base object. I also included verifier checks that the API can
visit all address uses for:

1. project_box.
2. alloc_stack.
3. ref_element_addr.
4. ref_tail_addr.
5. global_addr_inst.

this is because this visitor is now apart of the SIL API definition as being
able to enumerate /all/ addresses derived from a specific chosen address value.

This is a refactoring NFCI change.

rdar://108510644
…py] instead of a load_borrow.

The reason why I am doing this is that otherwise if one has a function that
takes both a guaranteed and an owned parameter, we will break OSSA invariants
since the load [take] will invalidate the load_borrow. So instead, we put in a
load_borrow knowing that the move checker will convert it to a load_borrow
assuming that the two pass exclusivity checking.

NOTE: Because of some missing functionality in subsequent tests, I had to
disable one test (moveonly_escaping_definite_initialization.swift) and also add
some checks for copy of noncopyable object errors. They will go away in the next
2 commits.

rdar://108510987
…opyable checking in the closure.

The reason why I am doing this is that currently SILGen knows when emitting said
closure that we are going to emit an error (that it does not have enough
information to emit itself since it doesn't know the caller), so doesn't emit
move checking markers. The result is that the move checker will not eliminate
any copies in the closure and thus will emit a "copy of noncopyable type found"
error and tell the user to file a bug. This just suppresses that.

rdar://108511866
…ble type, always emit mark_must_check.

The reason to do this is that:

1. Otherwise, we do not emit markers when someone attempts to consume the let.
We need the no_consume_or_assign to be there.
2. We need to insert assign_but_not_consuming so that DI can properly check lets
that are conditionally initialized and convert them to
initable_but_not_consuming.

I included a full definite_init SIL test that validates that we get the correct
codegen after DI in this case and emit the appropriate error as well.

rdar://108511534
…scaping closure behavior.

NOTE: We consider consuming closures that are marked without escaping as
non-escaping. We shouldn't do this, but for now I just included them so that
their behavior is in some test and we at least don't crash.
I left in the __owned tests of course.

rdar://108511703
…, do not suggest to the user to make a local copy.

It doesn't make sense to give this note since one can't make a copy of a
noncopyable type.

rdar://108511627
These are the same semantically, just the mangling is slightly different. The
benefit of doing this is that we are actually testing what we expect our users
to do.

rdar://108511703
That PR was for rdar://108385761
@gottesmm gottesmm force-pushed the pr-7fddccd1df47d4c57c27121727562d691b9f2397 branch from 02c0ebd to 9c8d224 Compare April 25, 2023 17:51
@gottesmm
Copy link
Contributor Author

@swift-ci test

@gottesmm
Copy link
Contributor Author

@swift-ci test source compatibility

@gottesmm
Copy link
Contributor Author

I discovered a small issue where I introduced an optnone by mistake. I am going to remove it in a follow on smoke test change.

@gottesmm
Copy link
Contributor Author

Actually I was wrong about the optnone. It was in my local branch that I am working with on top of this.

@gottesmm gottesmm changed the title [move-only] Two small batched changes [move-only] A group of batched changes Apr 25, 2023
@gottesmm
Copy link
Contributor Author

I took a look at the compatibility failure. One was a UPASS that showed up on the actual bot.

@gottesmm
Copy link
Contributor Author

The other failure is distributed actors which is also failing on other PRs due to misconfiguration. I talked with Konrad and he agreed I can ignore it.

@gottesmm gottesmm merged commit 94b0cae into swiftlang:main Apr 25, 2023
@gottesmm gottesmm deleted the pr-7fddccd1df47d4c57c27121727562d691b9f2397 branch April 25, 2023 23:14
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.

3 participants