-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
lowering: Keep track of which :enter correspond to which :leave #51590
Conversation
@nanosoldier |
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.
SGTM. I assume JuliaInterpreter will need a change to keep working after this. I think it would be best if we could merge that PR first, then this?
The package evaluation job you requested has completed - possible new issues were detected. |
|
This should be NFC and is intended to allow the optimizer to delete :enter statements (by replacing them with `nothing`), without leaving dangling `:leave`s around. This is accomplished by having `leave` take (a variable number of) `:enter` tokens (that are already being used by `:pop_exception`). The semantics are that a literal `nothing` or an SSAValue pointing to a `nothing` statement are ignored, and one exception handler is popped for each remaining argument. The actual value of the token is ignored, except that the verifier asserts that it belongs to an `:enter`. Note that we don't need to do the same for :pop_exception, because the token generated by an `:enter` is semantically only in scope for :pop_exception during its catch block. If we determine the `:enter` is dead, then its catch block is guaranteed to not be executed and will be deleted wholesale by cfg liveness. I was considering doing something fancier where :leave is changed back to taking an integer after optimization, but the case where the IR size is bigger after this change (when we are `:leave`ing many handlers) is fairly rare and likely not worth the additional complexity or time cost to do anything special. If it does show up in size benchmarks, I'd rather give `:leave` a special, compact encoding.
@nanosoldier |
The package evaluation job you requested has completed - no new issues were detected. |
This all looks good to go. I'll give @JeffBezanson a few hours to take a look if he wants, otherwise, I'll just merge this. |
Looks basically good, but I'm a bit worried about having cases where it's required to keep a |
You're allowed to delete it, you just need to propagate it to the usage side, which is always the case (e.g. for functions that return |
This leverages the support from #51590 to delete any try catch block that is known not to be triggered (either because the try-body is empty to because we have proven `:nothrow` for all contained statements).
This leverages the support from #51590 to delete any try catch block that is known not to be triggered (either because the try-body is empty to because we have proven `:nothrow` for all contained statements).
This leverages the support from #51590 to delete any try catch block that is known not to be triggered (either because the try-body is empty to because we have proven `:nothrow` for all contained statements).
This leverages the support from #51590 to delete any try catch block that is known not to be triggered (either because the try-body is empty to because we have proven `:nothrow` for all contained statements).
This should be NFC and is intended to allow the optimizer to delete :enter statements (by replacing them with
nothing
), without leaving dangling:leave
s around. This is accomplished by havingleave
take (a variable number of):enter
tokens (that are already being used by:pop_exception
). The semantics are that a literalnothing
or an SSAValue pointing to anothing
statement are ignored, and one exception handler is popped for each remaining argument. The actual value of the token is ignored, except that the verifier asserts that it belongs to an:enter
.Note that we don't need to do the same for :pop_exception, because the token generated by an
:enter
is semantically only in scope for :pop_exception during its catch block. If we determine the:enter
is dead, then its catch block is guaranteed to not be executed and will be deleted wholesale by cfg liveness.I was considering doing something fancier where :leave is changed back to taking an integer after optimization, but the case where the IR size is bigger after this change (when we are
:leave
ing many handlers) is fairly rare and likely not worth the additional complexity or time cost to do anything special. If it does show up in size benchmarks, I'd rather give:leave
a special, compact encoding.