-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Remove dead bridging calls for dead parameters #19797
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
Remove dead bridging calls for dead parameters #19797
Conversation
@swift-ci test |
@swift-ci benchmark |
Build comment file:Performance: -O
Code size: -O
Performance: -Osize
Code size: -Osize
Code size: Swift libraries
How 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 regressions before you merge the PR. Noise: Sometimes the performance results (not code size!) contain false alarms. Unexpected regressions which are marked with '(?)' are probably noise. If you see regressions which you cannot explain you can try to run the benchmarks again. If regressions still show up, please consult with the performance team (@eeckstein). Hardware Overview
|
Ah, nice! Is there a way to make |
Yes, the compiler could enforce this based on the annotation on the protocol requirement. |
@@ -356,6 +356,7 @@ extension DispatchData { | |||
return true | |||
} | |||
|
|||
@_effects(readonly) |
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.
Bad indent here
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.
interesting. This file has tab indents.
I'll fix it.
|
||
// REQUIRES: objc_interop | ||
|
||
// Check if the optimizer can remove dead briding calls. |
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 also CHECK-NOT that the witness table was not emitted?
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 test check the SIL. And in SIL the witness tables do get emitted.
For the IRGen part, I put in a CHECK-NOT in test/IRGen/objc_ns_enum.swift
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.
from the Foundation overlay this looks fine to me
one quick question however, does this apply to linux bridging as well? |
This avoids emitting synthesized witness tables if they are not needed.
…readonly) This enables removal of those bridging calls for dead parameters. Read-only lets the optimizer remove such a call if the result is not used. Note that "readonly" means: no observable write operations. It's okay to allocate and initialize new objects. rdar://problem/44944094
0a87574
to
6e6aae8
Compare
@swift-ci smoke test and merge |
1 similar comment
@swift-ci smoke test and merge |
@phausler good point. Yes, it would make sense to add the annotations in swift-corelibs-foundation as well. |
The benchmark output suggests NSStringConversion isn't doing any work anymore. Do we need to modify that test so that it actually performs the conversions? Or maybe there's some other test that covers that, and thus it's a good thing to have this test indicate that the work is skipped when the stores are dead? |
I'll fix the benchmark in a follow-up PR |
This PR consists of 2 changes:
lazily emit shared witness tables: This avoids emitting synthesized witness tables if they are not needed.
mark all _unconditionallyBridgeFromObjectiveC functions as @_effects(readonly): Read-only lets the optimizer remove such a call if the result is not used.
Note that "readonly" means: no observable write operations. It's okay to allocate and initialize new objects.
rdar://problem/44944094