Skip to content

[5.10][SILGen/DI] InitAccessors: Fix handling of nonmutating set when type has other stored properties #69104

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

xedin
Copy link
Contributor

@xedin xedin commented Oct 10, 2023

Cherry-pick of #68875


  • Explanation:

The original change supported only the case where all stored properties were controlled
by an init accessor but when other fields were involved SILGen would emitted copies of
loaded "self" for each setter application which is redundant and due to the fact that the
setter was escaping.

These changes make partial application of the setter non-escaping which means that
"self" can be borrowed instead of copied.

xedin added 3 commits October 10, 2023 13:24
The closure with applied base is not escaping and gets applied
only once (when self is fully initialized). Let's make sure that
the partial application results in on-stack closure that borrows
"self" instead of copying it.

(cherry picked from commit ab54ea7)
…sign_by_wrapper`

For cases where init accessor field has a nonmutating set we need
ignore copies and borrows associated with load of "self" because
they are going to be erased together with the setter application
by DI.

(cherry picked from commit 24c4fcc)
@xedin xedin added 🍒 release cherry pick Flag: Release branch cherry picks swift 5.10 labels Oct 10, 2023
@xedin xedin requested a review from hborla October 10, 2023 20:32
@xedin xedin requested a review from a team as a code owner October 10, 2023 20:32
@xedin
Copy link
Contributor Author

xedin commented Oct 10, 2023

@swift-ci please test

@xedin xedin merged commit 20940c2 into swiftlang:release/5.10 Oct 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🍒 release cherry pick Flag: Release branch cherry picks swift 5.10
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants