Skip to content

[silgenpattern] Change all loadable types to always go through the ownership preserving tuple code. #19840

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

[silgenpattern] Change all loadable types to always go through the ownership preserving tuple code.

To do this the commit does a few things:

  1. If we enter the tuple dispatch code with an address that is loadable, we
    always immediately perform a load_borrow and change the consumable managed value
    to BorrowAlways.

  2. If we have a take_on_success object, we immediately borrow. We do not want to
    do with TakeOnSuccess since we want to define away the need to unforward since
    unforwarding recreates a destroy on the already invalidated parent tuple object.

Notice that this code still handles TakeAlways so in simple cases where we have
a +1 value, everything still works.

Since emitTupleDispatchWithOwnership now handles only objects, I renamed it to
emitTupleObjectDispatch.

rdar://29791263


Note the commit in question is just the last commit. I have a string of commits that this is based upon that are being committed in other PRs: #19837 and #19838

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

@gottesmm
Copy link
Contributor Author

Going to consolidate these changes into 1 PR as per Slava's request.

@gottesmm gottesmm closed this Oct 11, 2018
@gottesmm
Copy link
Contributor Author

Or actually, I am going to use this 1 PR for all of them.

@gottesmm gottesmm reopened this Oct 11, 2018
…and only use BorrowAlways with objects.

The reason why the asserts were bogus is that even with SILOwnership enabled, we
will use the old pattern to emit address only code. In that case, the asserts
will fire on good behavior.

I also fixed a latent bug where when ownership was enabled we were treating
address only values like objects. Found via inspection.

rdar://29791263
This is really old code that I put in when I was still understanding
SILGenPattern. If we are emitting code in ownership form we will never have a
TakeOnSuccess consumption kind, so we should not forward in that case
"automagically".

rdar://29791263
…nership preserving tuple code.

To do this the commit does a few things:

1. If we enter the tuple dispatch code with an address that is loadable, we
always immediately perform a load_borrow and change the consumable managed value
to BorrowAlways.

2. If we have a take_on_success object, we immediately borrow. We do not want to
do with TakeOnSuccess since we want to define away the need to unforward since
unforwarding recreates a destroy on the already invalidated parent tuple object.

Notice that this code still handles TakeAlways so in simple cases where we have
a +1 value, everything still works.

Since emitTupleDispatchWithOwnership now handles only objects, I renamed it to
emitTupleObjectDispatch.

rdar://29791263
@gottesmm gottesmm force-pushed the pr-b1a0a45c5f7ddde8879ac6fcf10003e0805603f9 branch from fd7571a to 359eda5 Compare October 11, 2018 22:54
@gottesmm
Copy link
Contributor Author

@slavapestov I made the changes you requested to the first commit.

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

5 similar comments
@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

@gottesmm
Copy link
Contributor Author

@swift-ci smoke test

@gottesmm gottesmm merged commit aa118a7 into swiftlang:master Oct 12, 2018
@gottesmm gottesmm deleted the pr-b1a0a45c5f7ddde8879ac6fcf10003e0805603f9 branch October 12, 2018 00:16
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.

2 participants