Skip to content

[OpaqueValues] Return generic tuples directly. #61893

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

nate-chandler
Copy link
Contributor

Only create alloc_stacks for address-only tuple returns when using lowered addresses.

Based on #61887 .

Previously the API was only on FullApplySite, but it is useful to be
able to insert code after a partial_apply as well.
Rather than being able to handle only to FullApplySites, it now handles
PartialApplyInsts as well.
Use the CallArgRewriter to rewrite uses by partial_apply insts just as
uses by apply insts, etc., are rewritten.
When branching to the exit block, flatten an @out tuple return value
into its components, as is done for all other return values.

In the exit block, when constructing the @out tuple to return, visit the
tuple-type-tree of the return value to reconstruct the nested tuple
structure: @out tuple returns are not flattened, unlike regular tuple
returns.
Specify the operand ownership of the Builtin differently depending on
whether lowered addresses are used.  Handle rewriting the value version
of the builtin as the address version of the builtin in AddressLowering.
The variants are produced by SILGen when opaque values are enabled.
They are necessary because otherwise SILGen would produce
address_to_pointer of values.

They will be lowered by AddressLowering.
Now that generic values have been lowered to addresses, create the
address_to_pointer instructions.
Only create alloc_stacks for address-only tuple returns when using
lowered addresses.
@nate-chandler
Copy link
Contributor Author

@swift-ci please test

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.

For the record, I think we should remove Builtin.copy along with all these special cases to handle it.

@nate-chandler nate-chandler marked this pull request as ready for review November 3, 2022 21:46
@nate-chandler nate-chandler merged commit 94717da into swiftlang:main Nov 3, 2022
@nate-chandler nate-chandler deleted the opaque-values/2/20221102 branch November 3, 2022 21:46
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