Skip to content

Fix CastOptimizer for guaranteed values while handling checked_cast_br #37800

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 1 commit into from
Jun 16, 2021

Conversation

meg-gupta
Copy link
Contributor

Fixes rdar://77684045

@meg-gupta
Copy link
Contributor Author

@swift-ci test

@swift-ci
Copy link
Contributor

swift-ci commented Jun 4, 2021

Build failed
Swift Test Linux Platform
Git Sha - 6b98c1db715c70109c6c25f6482b1b03eed376f6

@meg-gupta
Copy link
Contributor Author

@swift-ci test Linux platform

@meg-gupta meg-gupta requested review from gottesmm and atrick June 7, 2021 16:54
@atrick
Copy link
Contributor

atrick commented Jun 7, 2021

In the interest of avoiding extra borrow scopes, I think we can replace the checked-cast's block argument (its terminator result) with the newly cast value instead of creating a degenerate phi.

@meg-gupta
Copy link
Contributor Author

@swift-ci test

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - 2a0e3ae580a6e2662f41a85e0d44f89678fd1ff5

@meg-gupta
Copy link
Contributor Author

@swift-ci test Linux platform

Fixes rdar://77684045. The rdar is about a SILVerifier assert for SIL created by
cast optimizer, where a guaranteed op of checked_cast_br iis transformed to an op of
a phi argument without creating borrow scope.

Fix:
During cast optimization, when the direction of checked_cast_br can be determined statically,
replace the success/failure value in the destination block and create an unconditional branch
to the destination block. This is done only in OSSA, since we ban critical edges.
@meg-gupta
Copy link
Contributor Author

@swift-ci smoke test

@meg-gupta
Copy link
Contributor Author

@atrick Sorry for the delay on this. I have fixed it by getting rid of the unnecessary borrow scope, and instead replace the success/failure value with the casted/original value.

Copy link
Contributor

@atrick atrick left a comment

Choose a reason for hiding this comment

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

Thanks!

@meg-gupta meg-gupta merged commit 2d7e6bf into swiftlang:main Jun 16, 2021
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