-
Notifications
You must be signed in to change notification settings - Fork 10.5k
SILOptimizer: allow function pointers in static globals and static global arrays. #35780
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
4f058ba
to
279c1b9
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
279c1b9
to
b00399d
Compare
@swift-ci test |
Build failed |
Build failed |
92771d2
to
383f8f6
Compare
@swift-ci test |
@swift-ci benchmark |
Build failed |
Performance: -O
Code size: -O
Performance: -Osize
Code size: -Osize
Performance: -OnoneCode size: -swiftlibsHow to read the dataThe tables contain differences in performance which are larger than 8% and differences in code size which are larger than 1%.If you see any unexpected regressions, you should consider fixing the Noise: Sometimes the performance results (not code size!) contain false Hardware Overview
|
@swift-ci test linux |
Build failed |
@swift-ci test macOS |
Build failed |
383f8f6
to
2cb0cf9
Compare
@swift-ci test |
Build failed |
If we know that we have a FunctionRefInst (and not another variant of FunctionRefBaseInst), we know that getting the referenced function will not be null (in contrast to FunctionRefBaseInst::getReferencedFunctionOrNull). NFC
…uctions in an initializer of a SILGlobalVariable. This means: don't require to have a SILFunction in the SILBuilder.
It makes sense to to this in a single pass, because there might be dead cycles for globals and functions, e.g. if a global references a function in its static initializer and the function references that global. Another improvement: eliminate dead global-initializers. Before we had an explicit SIL representation of statically initialized globals, we had to keep them alive. rdar://32956923
The main change is to rename DeadFunctionElimination -> DeadFunctionAndGlobalElimination, because the pass is now also doing dead-global elimination. A second change is to remove the FunctionLivenessComputation base class. It’s not used anywhere else.
…in global variables. We cannot replace a load from a global let-variable with a function_ref, if the referenced function would violate the resilience rules. That means if a non-public function_ref would be inlined into a function which is serialized.
Just moving a few functions around and make emitConstantValue the main entry point for creating constants. NFC
…obal arrays. For example, generate a static global for the array literal in: func foo(_ i: Int) -> Int { ... } func bar(_ i: Int) -> Int { ... } func returnFunctionArray() -> [(Int) -> Int] { return [foo, bar] } rdar://73570149 https://bugs.swift.org/browse/SR-14101
2cb0cf9
to
0a483a6
Compare
@swift-ci test |
In case a function is only referenced from a global without a declaration (e.g. an outlined global), we could end up with a null IRGenModule for the function (with multithreaded compilation). In this case, just use the primary IGM. This fixes a IRGen crash, introduced with swiftlang#35780 rdar://74358251
…lobals. This fixes a IRGen crash, introduced with swiftlang#35780 rdar://74358259
For example, generate a static global for the array literal in:
rdar://73570149
https://bugs.swift.org/browse/SR-14101
This PR also contains an improvement of DeadFunctionElimination: it now can also remove dead global variables.
Handling function references in global initializers is required in DeadFunctionElimination anyway. It was only a small addition to implement dead global variable elimination in the same change.
rdar://32956923