-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[sil-opt] Fix covering all-case of trapping instruction of SILInstruction::mayTrap #33851
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
If the current one is correct, I think it would be better to add some comments of it to source code, what do you think? |
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 add a test case in https://github.com/apple/swift/blob/master/test/SILOptimizer/side-effect.sil
As an example, see the test function "sil @checkedcast".
Otherwise LGTM!
Oh, sorry for not adding test, let me add it! 👍 |
…ional_checked_cast_value at side-effect.sil
I added test of If no |
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, thanks!
Thank you for reviewing! |
Should I run test? |
@swift-ci please test |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@swift-ci please test macOS |
@swift-ci please test Windows |
@swift-ci please test macOS |
Build failed |
macOS failure should be fixed once swiftlang/swift-package-manager#2924 is merged. |
@swift-ci please test macOS platform |
Hi, I found that the function which checking trapping SIL instruction may have an issue, so I want to fix by this PR.
(moved from #33830 to fix commit comment)
Abstract
Making
SILInstruction:: mayTrap
covering all cases of trapping instruction.Issue
Having no issue-report
Description
It seems that
SILInstruction::mayTrap()
is checking that the instruction may trap or not.And, according to the sil.rst, there are 4 instruction may trap (runtime-failure).
cond_fail
unconditional_checked_cast
unconditional_checked_cast_addr
unconditional_checked_cast_value
ref: https://github.com/apple/swift/blob/master/docs/SIL.rst#cond_fail and https://github.com/apple/swift/blob/master/docs/SIL.rst#checked-conversions
However,
unconditional_checked_cast_value
is missed onmayTrap
case in current implementation so this commit added it to cover all-case.This missing case has a risk to remove instruction which should be marked as side-effect, on like Dead Code Elimination, so should be fixed