-
Notifications
You must be signed in to change notification settings - Fork 729
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
Add extra Simplifier & gotoElim passes to warm/hot #20127
Add extra Simplifier & gotoElim passes to warm/hot #20127
Conversation
Jenkins test sanity.functional xlinux|plinux|zlinux jdk11,jdk17 depends eclipse-omr/omr#7456 |
Jenkins test sanity.functional xlinux,plinux,zlinux jdk11,jdk17 depends eclipse-omr/omr#7456 |
In the case of And now that I'm looking at it, I should ask the same question of |
If Simplifier detects trivial conditional branches where the fallthrough block is a goto block to the branch target it can remove said branches and leave behind a goto block. The resulting CFG can then potentially be cleaned up by RedundantGotoElimination. Running these two opts before BlockSplitter allows these trivial conditional branches to be completely optimized away before BlockSplitter gets a change to run and potentially duplicate blocks that hide the opportunity and make it harder to detect and eliminate later. This PR inserts Simplifer and RedundantGotoElimination passes before BlockSplitter and moves all 3 after VP, which typically detects opportunities that result in dead code, which when removed, results in the trivial conditional branches that we're interested in. Signed-off-by: Younes Manton <[email protected]>
56c9066
to
8d9a6bd
Compare
|
Jenkins test sanity.functional xlinux,plinux,zlinux jdk11,jdk17 depends eclipse-omr/omr#7456 |
Ah! Thanks for pointing that out. |
The failures look like an exposed bug in BlockSplitter. Crashes happen in local VP because its processing a conditional branch node and expects to find an edge in the CFG to the node's target, but doesn't. Looking back through the trace log it looks to me like BlockSplitter goes off the rails and doesn't properly update the CFG.
block_19 and block_12 exist prior to this pass of BlockSplitter.
block_19 ends with a trivial conditional branch to block_12. BlockSplitter clones block_19 and block_12 and creates the corresponding block_109 and block_110.
It then clones block_109 to get block_114, but doesn't clone block_110, which means that (I don't know why block_115 was created, it's not mentioned in the log, but it looks OK in the CFG at least.)
|
Maybe it is better to run with tree and CFG verification enabled to make sure everything was valid before block splitter ran. It would be good to make sure of that since it would be a bit surprising to have it do transformations correctly in every other case, but start failing to do so after the recent changes in strategy. |
CFG verification doesn't find any problem unfortunately. This bug is only reproducible with #20090 in the mix, which went in a couple of weeks ago and seems to change the IL around unsafe ops. Without those changes in the build I can't reproduce the crash we're seeing here, so it's possible that we're seeing some new CFG shapes that we weren't previously. Continuing to look. |
I believe the bug is in this part of BlockSplitter:
The above code wants cloned blocks C to rejoin the original path of execution E, so it creates a goto block G, adds edges C -> G and G -> E, and removes C -> E. The problem looks to me like it does not recognize the case where the conditional branch target of C also goes to E, so the C -> E edge represents both the fall-through and branch target and can't be removed. Tracing the above code I can see that in cases where the branch target is not the fall-through path it works as intended, the fall-through edge is removed and the branch target edge remains and the CFG stays correct, but when the branch target is the fall-through path the C -> E edge is always missing after BlockSplitter runs. The options I see are
With the change in eclipse-omr/omr#7456 Simplifier will now recognize (1) and be able to eliminate it, but (2) might be better because I think more opts will spot it and be able to eliminate it (e.g. RedundantGotoElimination). |
Tested both options locally and they appear to work as expected. Pushed option 2 to eclipse-omr/omr#7456 for PR testing. |
Jenkins test sanity.functional xlinux,plinux,zlinux jdk11,jdk17 depends eclipse-omr/omr#7456 |
The s390x jobs failed because of instances of #20150.
which is not related to the changes in these PRs as far as I can tell. |
In above example you mentioned, is there an assumption that G will be added as a fall through block for C ? |
Yes, G is always being made to follow C in the above code, so it will always represent the fall-through path. |
The change itself is quite safe (just adds a couple of passes to optimization strategies). Should we also make similar changes for very hot and scorching optimization strategies ? |
Those strategies already have these passes happening in between GVP and BlockSplitter, so we're good there. |
If Simplifier detects trivial conditional branches where the fallthrough
block is a goto block to the branch target it can remove said branches
and leave behind a goto block. The resulting CFG can then potentially
be cleaned up by RedundantGotoElimination. Running these two opts
before BlockSplitter allows these trivial conditional branches to be
completely optimized away before BlockSplitter gets a change to run and
potentially duplicate blocks that hide the opportunity and make it
harder to detect and eliminate later.
This PR inserts Simplifer and RedundantGotoElimination passes before
BlockSplitter and moves all 3 after VP, which typically detects
opportunities that result in dead code, which when removed, results
in the trivial conditional branches that we're interested in.
This PR is made more effective by eclipse-omr/omr#7456.