Skip to content

[SILGen] Add SILDeclRef for main entry-point #37014

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
merged 4 commits into from
May 19, 2021

Conversation

hamishknight
Copy link
Contributor

Allow SILDeclRef to refer to the main program entry-point, which will either be for a main SourceFile, or a synthetic main such as an @main decl. Adjust the various SILDeclRef related functions to handle this new case, and change the emission to go through emitFunctionDefinition.

This change will allow the entry-point for an @main decl (and eventually a main SourceFile) to be emitted on-demand from its symbol name.

@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight
Copy link
Contributor Author

@swift-ci please test source compatibility

This will make it easier to store in a SILDeclRef.
This will be used to represent the entry-point
for a main SourceFile.
Allow SILDeclRef to refer to the main program
entry-point, which will either be for a main
SourceFile, or a synthetic main such as an `@main`
decl. Adjust the various SILDeclRef related
functions to handle this new case, and change the
emission to go through `emitFunctionDefinition`.

This change will allow the entry-point for an `@main`
decl (and eventually a main SourceFile) to be
emitted on-demand from its symbol name.
Now that SILDeclRef can represent the main function,
tweak TBDGen to refer to it.
@hamishknight
Copy link
Contributor Author

@swift-ci please test

@swiftlang swiftlang deleted a comment from swift-ci Apr 26, 2021
@hamishknight
Copy link
Contributor Author

@swift-ci please test macOS

Copy link
Contributor

@CodaFi CodaFi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that we're using more of the built-in machinery in SILGen to emit this entrypoint. The changes here look good, in particular to TBDGen. I'm going to tag @eeckstein for a closer look at the SILDeclRef representation changes for which I have much less experience.

@hamishknight hamishknight requested a review from eeckstein April 27, 2021 12:01
Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, though it would be good if @slavapestov could also take a look.

@hamishknight
Copy link
Contributor Author

@swift-ci please test

@hamishknight hamishknight merged commit ed104a8 into swiftlang:main May 19, 2021
@hamishknight hamishknight deleted the entry-sign branch May 19, 2021 07:32
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.

4 participants