Skip to content

Conversation

@zoecarver
Copy link
Contributor

This PR adds an experimental feature: Embedded (swift). It starts implementing the feature by during on mandatory optimizations (specialization, devirtualization, inlining, etc.) for all functions and applying mandatory performance diagnostics. It also adds a number of asserts to IRGen to ensure we don't emit anything that we shouldn't.

Next steps will be serializing all functions in all modules when embedded Swift is enabled. We will probably need some more IRGen work along the way (and maybe some more optimizations/fixes). Then we can move on to the standard library.

See Kuba's forum post https://forums.swift.org/t/embedded-swift/67057

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@kubamracek we want to require whole module optimization, right? That should probably be implicit though. I can add that in a follow-up patch.

Copy link
Contributor

Choose a reason for hiding this comment

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

implicit

Not sure about that. I think I would prefer erroring out if WMO is not enabled. (Possibly we could allow building single-file modules without WMO.) Okay to do as a follow-up, yes.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, at least for now we need to require WMO

Copy link
Contributor

Choose a reason for hiding this comment

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

this needs to be guarded with hasFeature(Embedded), right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes you're right.

@kubamracek kubamracek requested a review from jckarter August 31, 2023 19:21
Copy link
Contributor

Choose a reason for hiding this comment

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

Generic functions shouldn't be added. They will be optimized once they are specialized

Copy link
Contributor

Choose a reason for hiding this comment

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

Also this loop does not belong to addAllPerformanceAnnotatedFunctions, because it has nothing to do with performance annotated functions. I suggest to move it to its own function.

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, at least for now we need to require WMO

Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we assert that those lazy lists are empty?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, but for now we need this for it to compile. Let's make these asserts as a follow up (they will require investigation).

Copy link
Contributor

Choose a reason for hiding this comment

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

@zoecarver
Copy link
Contributor Author

@swift-ci please test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@eeckstein can you double check this?

Copy link
Contributor

Choose a reason for hiding this comment

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

lgtm!

Copy link
Contributor

Choose a reason for hiding this comment

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

addAllPerformanceAnnotatedFunctions and addAllAnnotatedGlobalInitOnceFunctions should be called in the else-branch of this if-statement

Copy link
Contributor

Choose a reason for hiding this comment

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

lgtm!

Copy link
Contributor

Choose a reason for hiding this comment

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

typo nit

Suggested change
/// Witness methods, boxing, unboxing, itializting, etc.
/// Witness methods, boxing, unboxing, initializing, etc.

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!

@zoecarver
Copy link
Contributor Author

@swift-ci please smoke test

@zoecarver
Copy link
Contributor Author

@swift-ci please smoke test

@zoecarver zoecarver added the embedded Embedded Swift label Sep 6, 2023
@zoecarver zoecarver merged commit 74e22dc into swiftlang:main Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

embedded Embedded Swift

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants