Skip to content

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

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

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

@swift-ci Please test source compatibility

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 7, 2021

@swift-ci Please test source compatibility

@jckarter
Copy link
Contributor Author

jckarter commented Sep 7, 2021

@swift-ci Please test

@swift-ci
Copy link
Contributor

swift-ci commented Sep 7, 2021

Build failed
Swift Test Linux Platform
Git Sha - 6e4838db0272de2eda0efdc1fa378068527dcc8e

@jckarter
Copy link
Contributor Author

jckarter commented Sep 8, 2021

@swift-ci Please test Linux

@jckarter jckarter force-pushed the emit-closure-literal-at-context-abstraction-2 branch from 6e4838d to 43506a2 Compare September 8, 2021 17:45
@jckarter
Copy link
Contributor Author

jckarter commented Sep 8, 2021

@swift-ci Please test

@jckarter
Copy link
Contributor Author

jckarter commented Sep 8, 2021

@swift-ci Please test source compatibility

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