-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[embedded] Lay the groundwork for embedded Swift #68244
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
lib/Frontend/CompilerInvocation.cpp
Outdated
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes you're right.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
lib/Frontend/CompilerInvocation.cpp
Outdated
There was a problem hiding this comment.
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
lib/IRGen/GenDecl.cpp
Outdated
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to define an "Existential" runtime effect here https://github.com/apple/swift/blob/main/include/swift/SIL/RuntimeEffect.h and add those instructions in swift::getRuntimeEffect https://github.com/apple/swift/blob/99a36b3f00cc98c11e4bb674c9ea743d448ac0d2/lib/SIL/Utils/InstructionUtils.cpp#L438
bc6a15a to
1466a69
Compare
|
@swift-ci please test |
include/swift/SIL/RuntimeEffect.h
Outdated
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
There was a problem hiding this comment.
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
include/swift/SIL/RuntimeEffect.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
include/swift/SIL/RuntimeEffect.h
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo nit
| /// Witness methods, boxing, unboxing, itializting, etc. | |
| /// Witness methods, boxing, unboxing, initializing, etc. |
Optimize all functions in embedded mode. Diagnose any uses of existentials or witness tables.
…cs on embedded feature being enabled.
eeckstein
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
1466a69 to
5203053
Compare
|
@swift-ci please smoke test |
|
@swift-ci please smoke test |
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