Skip to content

Optimizer: add the ObjCBridgingOptimization to optimize ObjectiveC bridging operations. #58888

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
merged 3 commits into from
Jun 9, 2022

Conversation

eeckstein
Copy link
Contributor

Removes redundant ObjectiveC <-> Swift bridging calls.
Basically, if a value is bridged from ObjectiveC to Swift an then back to ObjectiveC again, then just re-use the original ObjectiveC value.

Also, add an additional DCE pass before ownership elimination. It can cleanup dead code which is left behind by the ObjCBridgingOptimization.

This PR also removes an old obsolete bridging optimization from SILCombine.

rdar://89987440

@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein
Copy link
Contributor Author

@swift-ci benchmark

/// none_bb:
/// %5 = enum #none
/// br continue_bb(%5)
/// continue_bb(%bridgedOptionalSwiftVaule):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(very minor) Typo

Copy link
Contributor

@mikeash mikeash left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hooray!

let originalObjCValue = bridgeToSwiftCall.arguments[0]
let optionalObjCType = originalObjCValue.type

// The briding functions from ObjC -> Swift take an optional argument and return a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(very minor) Another typo, should be "bridging". (Sorry, just reading through this out of interest.)

@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein
Copy link
Contributor Author

@swift-ci test

eeckstein added 3 commits June 8, 2022 22:51
In case of type-dependent operands, not all operands are part of the arguments
…idging operations.

Removes redundant ObjectiveC <-> Swift bridging calls.
Basically, if a value is bridged from ObjectiveC to Swift an then back to ObjectiveC again, then just re-use the original ObjectiveC value.

Also in this commit: add an additional DCE pass before ownership elimination. It can cleanup dead code which is left behind by the ObjCBridgingOptimization.

rdar://89987440
It's replaced by the new ObjCBridgingOptimization optimization pass
@eeckstein
Copy link
Contributor Author

@swift-ci test

@eeckstein eeckstein merged commit b3d9b87 into swiftlang:main Jun 9, 2022
@eeckstein eeckstein deleted the objc-string-opt branch June 9, 2022 04:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants