-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Add -internalize-at-link flag to allow dead stripping and VFE across modules at link time #39214
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/IRGen/GenMeta.cpp
Outdated
@@ -1782,7 +1791,13 @@ namespace { | |||
// method for external clients. | |||
|
|||
// Emit method dispatch thunk. | |||
if (hasPublicVisibility(fn.getLinkage(NotForDefinition))) { | |||
bool shouldEmitDispatchThunk = false; |
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.
Can this logic, which is the same as the previous change, be extracted into a utility function?
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 wasn't entirely identical, so I've instead simplified it into just an or-d expression inside the if.
2c2c144
to
97d3f16
Compare
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
lib/IRGen/IRGenSIL.cpp
Outdated
if (IGM.hasResilientMetadata(classDecl, ResilienceExpansion::Maximal)) { | ||
shouldUseDispatchThunk = true; | ||
} else if (IGM.getOptions().VirtualFunctionElimination) { | ||
// For VFE, use a thunk if the target class is in another module. |
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.
Can you add a comment why this is needed?
71f21d2
to
69bef5e
Compare
…modules at link time - Under -internalize-at-link, stop unconditionally marking all globals as used. - Under -internalize-at-link, restrict visibility of vtables to linkage unit. - Emit virtual method thunks for cross-module vcalls when VFE is enabled. - Use thunks for vcalls across modules when VFE is enabled. - Adjust TBDGen to account for virtual method thunks when VFE is enabled. - Add an end-to-end test case for cross-module VFE.
@swift-ci please test |
Build failed |
@swift-ci please test Linux platform |
The first commit in the PR is being reviewed at #39128. Suggestion for reviewers is to only look at the second commit here.