-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Improve EH dead code elimination #93428
Improve EH dead code elimination #93428
Conversation
Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch Issue DetailsUpdate This causes more dead code to be eliminated in handlers that are not reachable. There is a little more work to do to completely clean these up:
Contributes to #82335
|
@AndyAyersMS PTAL |
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
We encode EH region numbers into the AddCodeDsc entries (starting in morph) so if we remove things from the EH table we'll need to fix these up too. Or perhaps rework all this so these entries hang off the EH table somehow and migrate organically along with their related regions. |
In particular, using |
Update `fgRemoveDeadBlocks()` to only treat EH handlers as reachable if their corresponding `try` block entry is reachable. This causes more dead code to be eliminated in handlers that are not reachable. There is a little more work to do to completely clean these up: 1. If a `try` is not reachable, we should get rid of its entire EH table entry. Currently, its block is generated as `int3` (on xarch). 2. Even though the handler is not reachable, we still generate the prolog followed by `int3` for the body. Contributes to dotnet#82335
fgRemoveBlockAsPred had special handling to not decrease the bbRefs count of the filter-handler targeted by BBJ_EHFILTERRET. This is incorrect, as the filter-handler already has an extra "beginning of handler" extra ref count. Possibly this code was never invoked before as filters were not previously removed. Also, fix the JitDump output of the filter ret block in block dumps.
da5b551
to
335e2d3
Compare
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 that we don't see much of a TP win here.
I wonder if we should try doing this earlier?
Would you expect a TP win because of less IR? It seems like unreachable handlers should be rare, especially after the early EH opts. This still doesn't remove an unreachable
Seems like it needs to be late enough for all the normal opts creating dead flow to run. |
/azp run runtime-coreclr jitstress |
Azure Pipelines successfully started running 1 pipeline(s). |
Test failure is #93506 |
Update
fgRemoveDeadBlocks()
to only treat EH handlers as reachable if their correspondingtry
block entry is reachable.This causes more dead code to be eliminated in handlers that are not reachable.
There is a little more work to do to completely clean these up:
try
is not reachable, we should get rid of its entire EH table entry. Currently, its block is generated asint3
(on xarch).int3
for the body.Contributes to #82335