Skip to content

SILGen: Emit literal closures at the abstraction level of their context. [take 3] #39233

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

Conversation

jckarter
Copy link
Contributor

@jckarter jckarter commented Sep 9, 2021

Literal closures are only ever directly referenced in the context of the expression they're written in,
so it's wasteful to emit them at their fully-substituted calling convention and then reabstract them if
they're passed directly to a generic function. Avoid this by saving the abstraction pattern of the context
before emitting the closure, and then lowering its main entry point's calling convention at that
level of abstraction. Generalize some of the prolog/epilog code to handle converting arguments and returns
to the correct representation for a different abstraction level.

This take includes additional fixes for failures found in the compatibility suite.

Literal closures are only ever directly referenced in the context of the expression they're written in,
so it's wasteful to emit them at their fully-substituted calling convention and then reabstract them if
they're passed directly to a generic function. Avoid this by saving the abstraction pattern of the context
before emitting the closure, and then lowering its main entry point's calling convention at that
level of abstraction. Generalize some of the prolog/epilog code to handle converting arguments and returns
to the correct representation for a different abstraction level.
@jckarter
Copy link
Contributor Author

jckarter commented Sep 9, 2021

@swift-ci Please test

@jckarter
Copy link
Contributor Author

jckarter commented Sep 9, 2021

@swift-ci Please test source compatibility

@swift-ci
Copy link
Contributor

swift-ci commented Sep 9, 2021

Build failed
Swift Test Linux Platform
Git Sha - fdc0e08

@jckarter
Copy link
Contributor Author

jckarter commented Sep 9, 2021

@swift-ci Please test Linux

@jckarter jckarter merged commit 4553b8f into swiftlang:main Sep 10, 2021
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