Skip to content

[5.9] More batched changes #66196

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
merged 13 commits into from
Jun 5, 2023

Conversation

gottesmm
Copy link
Contributor

@gottesmm gottesmm commented May 28, 2023

This PR contains a set of batched commits for 5.9. A few of the commits were
test tweaks so I did not include CCC for them.

Commit 6a5ef8a
• Description: [move-only] Make sure that we serialize deinits and if we are not
able to see the value witness function, call it via the value witness
function.
• Risk: Low. This only affects noncopyable types.
• Original PR: #66185
• Reviewed By: @jckarter
• Testing: I put in both a swiftpm like test case and a library evolution test
case. I also updated the moveonly_deinit serialization swift test to show that
we actually serialize the deinit.
• Resolves: rdar://109679168

Commit 5530aa9

• Description: [move-only] Teach deinit devirtualization how to handle
devirtualizing a deinit of a resilient type.
• Risk: Low. This only affects noncopyable types.
• Original PR: #66185
• Reviewed By: @jckarter
• Testing: I added tests that exercised this behavior.
• Resolves: rdar://109904633

Commit 45a592c
• Description: [move-only] Change closure capture diagnostic for let patterns to
say that it cannot be captured by an escaping closure.
• Risk: Low. This only affects noncopyable types.
• Original PR: #66197
• Reviewed By: @jckarter
• Testing: Updated tests to show we emit the correct diagnostic.
• Resolves: rdar://109742587

Commit 20bf5d5
• Description: [move-only] Teach SILGenApply how to emit subscripts with borrowed base values.
• Risk: Low. This only affects noncopyable types.
• Original PR: #66094
• Reviewed By: @jckarter
• Testing: Added exhaustive tests in this area to test out the behavior
• Resolves: rdar://109746476

Commit c009c32
• Description: [move-only] When we emit a noncopyable temporary allocation,
always attach a mark_must_check [consumable_and_assignable]. This removes most
of the copy of noncopyable type errors seen in the tests from
20bf5d5
• Risk: Low. This only affects noncopyable types.
• Original PR: #66094
• Reviewed By: @jckarter
• Testing: Added exhaustive tests in this area to test out the behavior
• Resolves: rdar://109746476

Commit 61745ee
• Description: [move-only] Make sure that we handle load [take] that are
actually borrows correctly.
• Risk: Low. This only affects noncopyable types.
• Original PR: #66094
• Reviewed By: @jckarter
• Testing: Added SIL tests that show that we have the correct behavior here
• Resolves: rdar://109746476

Commit 23deccf
• Description: Restricts c009c32 so we only
perform the transformation on reads instead of also gets.
• Risk: Low. This only affects noncopyable types.
• Original PR: #66094
• Reviewed By: @jckarter
• Testing: Updated silgen tests that show this behavior. Updated the subscript
tests so that they validate that we do not have copy of noncopyable errors in
the places that this change fixes.
• Resolves: rdar://109746476

Commit 1ae66b2
• Description: [move-only] Teach SILGen how to recognize a borrowed read
subscript when the type also has a modify.
• Risk: Low. This only affects noncopyable types.
• Original PR: #66094
• Reviewed By: @jckarter
• Testing: Updated silgen tests that show this behavior. Updated the subscript
tests so that they validate that we do not have copy of noncopyable errors in
the places that this change fixes.
• Resolves: rdar://109746476

@gottesmm gottesmm requested a review from a team as a code owner May 28, 2023 19:34
@gottesmm
Copy link
Contributor Author

@swift-ci test

2 similar comments
@gottesmm
Copy link
Contributor Author

@swift-ci test

@gottesmm
Copy link
Contributor Author

@swift-ci test

@gottesmm gottesmm force-pushed the release-5.9-more-stuff-2 branch from 84454da to b2fe8dc Compare June 1, 2023 22:11
gottesmm and others added 11 commits June 2, 2023 13:27
…e to see the value witness function, call it via the value witness function.

Some notes:

1. I put in both a swiftpm like test case and a library evolution test case. I
also updated the moveonly_deinit serialization swift test to show that we
actually serialize the deinit.

2. I changed when we emit the deinit table to only be when we have a type with
an actual value type destructor. Notably this doesn't include classes today so
as a side-effect, we no longer attempt to devirtualize moveonly class deinits.
This doesn't affect anything we are trying to actually do since we do not
support noncopyable classes today. With that in mind, I changed one test that
was showing that deinit devirtualization worked to use a struct with deinit
instead of a class.

rdar://109679168
(cherry picked from commit 8579c19)
…g a deinit of a resilient type.

Specifically, such a type has an @in convention for its deinit and the pass was
setup expecting self to always be @owned.

rdar://109904633
(cherry picked from commit 1d04df9)
(cherry picked from commit a52302d)
… that it cannot be captured by an escaping closure.

rdar://109742587
(cherry picked from commit 577e76b)
…se values.

I also added a bunch of tests that showed the behavior of subscripts/other accessors with the following combinations of semantics:

1. get only.
2. get/set.
3. get/modify.
4. read/set.
5. read/modify.

rdar://109746476
(cherry picked from commit 508bf8a)
…ttach a mark_must_check [consumable_and_assignable].

Most of the time SILGen already emits these correctly without having extra
copies, but in certain situations SILGen will emit copies that we need the move
checker to eliminate (e.x.: when we generate a yield). An additional benefit is
that this also will catch places where the frontend makes a mistake.

This also removes a bunch of "copy of noncopyable" types error that showed up in
the implicit compiler generated modify.

(cherry picked from commit 5d9ab63)
…rrows correctly.

Before the previous commit, we didn't see load [take] very often since it occurs
mostly on temporaries where we treat the copy_addr as the relevant take. Now
that we are checking temporaries though, we need to support this behavior.

(cherry picked from commit c9edaee)
…_read accessor.

We want the result of getters to still be separate values.

(cherry picked from commit 7b66c70)
…hen the type also has a modify.

The form of the AST changes slightly when a type has a read and a modify.
Specifically, we now have a load on the subscript and an inout_expr on the base.
I dealt with this by making the inout_expr something that when we look for
storage we look through and by tweaking the load lookthrough code.

(cherry picked from commit 2b785e4)
…none so we can make sure it works even without opts.

(cherry picked from commit c0ce58c)
The member just clears the values.  After it adopted BitfieldRef, the
call to invalidate on the liveness instance was already superfluous.

(cherry picked from commit 3c4275a)
@gottesmm gottesmm force-pushed the release-5.9-more-stuff-2 branch from b2fe8dc to ffa9119 Compare June 2, 2023 20:27
@gottesmm
Copy link
Contributor Author

gottesmm commented Jun 2, 2023

@swift-ci test


// If we do not have a deinit table, call the value witness instead.
if (!deinitTable) {
irgen::emitDestroyCall(IGF, T, indirect());
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to call indirectCleanup after the call to indirect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will prepare a small patch on main that will fix this. Why don't you give the +1 and then I can get TimK to +1 this and I can take care of this tonight/over the weekend.

Copy link
Contributor

@jckarter jckarter left a comment

Choose a reason for hiding this comment

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

This should be safe to land now without the indirectCleanup change, which is minor enough to do in a follow-up commit.

@gottesmm
Copy link
Contributor Author

gottesmm commented Jun 5, 2023

@swift-ci test

@gottesmm gottesmm merged commit 756d440 into swiftlang:release/5.9 Jun 5, 2023
@gottesmm gottesmm deleted the release-5.9-more-stuff-2 branch June 5, 2023 15:00
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.

4 participants