-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[5.9] Introduce -unavailable-decl-optimization=stub
#65269
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
tshortli
merged 14 commits into
swiftlang:release/5.9
from
tshortli:unavailable-decl-optimization-stub-5.9
May 7, 2023
Merged
[5.9] Introduce -unavailable-decl-optimization=stub
#65269
tshortli
merged 14 commits into
swiftlang:release/5.9
from
tshortli:unavailable-decl-optimization-stub-5.9
May 7, 2023
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31835e4
to
d2c7a51
Compare
@swift-ci please test |
1 similar comment
@swift-ci please test |
20d657a
to
c3e0a89
Compare
@swift-ci please test |
Part of rdar://107388493
When `-unavailable-decl-optimization=stub` is specified, insert a call to `_diagnoseUnavailableCodeReached()` at the beginning of the function to cause it to trap if executed at run time. Part of rdar://107388493
…tubs. User code should not be diagnosed as "unreachable" by the SIL optimizer when the no-return function that made the code unreachable is a compiler inserted call to `_diagnoseUnavailableCodeReached()`. Part of rdar://107388493
Part of rdar://107388493
Part of rdar://107388493
Part of rdar://107388493
Part of rdar://107388493
…thunk. Part of rdar://107388493.
The logic was defaulting to `arm64` when a binary only contained `amr64_32` and `arm64e` slices.
05f017b
to
7c29f8c
Compare
nkcsgexi
approved these changes
May 5, 2023
This is a mode behind an opt-in flag so it should be safe to be landed on 5.9 |
@swift-ci please test |
5637532
to
8c45bb2
Compare
@swift-ci please test |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Cherry pick of #65557
Implement a new
-unavailable-decl-optimization
mode that replaces the bodies of unavailable functions with calls to a standard library function that invokesfatalError
. Unlike-unavailable-decl-optimization=complete
, this compilation mode is designed to improve the code size of unavailable code while also preserving ABI compatibility. This is important since there are existing compiled binaries that link the symbols for unavailable functions even though those symbols should be provably unreachable.This optimization is implemented in SILGen by inserting a call to a new standard library function
_diagnoseUnavailableCodeReached()
in the prologue of each unavailable function. The existing dead code elimination optimization pass then determines that the remainder of the function body is unreachable and removes all other code, leaving the body of the function as a single call to a no-return function.There are several follow up changes that can be made to maximize the effectiveness of this optimization:
_diagnoseUnavailableCodeReached()
and sometimes also includes abrk
instruction after the call. Some work to reduce the machine code for these stubs down to the minimal necessary instructions (probably just a single branch?) may be warranted.Resolves rdar://107388493