-
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
8268019: C2: assert(no_dead_loop) failed: dead loop detected #4860
Conversation
👋 Welcome back chagedorn! A progress list of the required criteria for merging this PR into |
@chhagedorn The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
Ping - due to outage |
src/hotspot/share/opto/ifnode.cpp
Outdated
if (r->is_Loop()) return NULL; | ||
if( phi->region() != r ) return NULL; | ||
Node* r = iff->in(0); | ||
if (!r->is_Region() || r->is_Loop() || phi->region() != r) { |
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.
May be also add || r->as_Region()->is_copy() || igvn->_worklist.member(r)
checks.
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.
Could we then possibly miss a split if opportunity when bailing out with igvn->_worklist.member(r)
? Should we readd the If
node to the worklist in this case? We could also think about adding igvn->_worklist.member(r)
further down when we are really sure that we could do a split if.
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.
My thinking is that Region could go away after it is processed (when input[s] are dead/top). Why bother to split through it?
I am concern that you are checking dead inputs by hand in these changes - input's transformation to Top should put Region node on worklist. Can you do experiment without your dead inputs check and only checking worklist?
I think the issue (as usual) is the order of processing of worklist. That is why I suggested this check.
Yes, you can delay worklist checking to see if we should put If node back on worklist only when we can do split if.
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.
You're right, this additional worklist check should then be enough and is more clean. I reverted the fix and added a worklist check at the latest possible location. This works for repeated runs with StressIGVN
+ RepeatCompilation
. I also included the is_copy()
check.
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.
Good.
@chhagedorn This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 208 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
Thanks Vladimir for your review! |
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.
Nice analysis. Looks good to me.
And just for the record: We need to be careful to not create an infinite loop of node processing when "manually" re-adding nodes that haven't changed to the worklist. For example, while processing node A, it is re-added to the worklist because node B is still on the worklist. Then while node B is processed, it's also re-added to the worklist because node A is still on the worklist and so on. I don't think that's an issue here but I've debugged similar bugs in the past in Valhalla. |
Thank you for your review Tobias!
That's a good point to keep in mind. I also think it's fine in this case but in general we need to be careful when doing it. |
/integrate |
Going to push as commit 489e5fd.
Your commit was automatically rebased without conflicts. |
@chhagedorn Pushed as commit 489e5fd. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
In the testcase, a path containing a loop is found to be dead. These nodes are then removed during IGVN after parsing (before loop opts). One of these nodes is a loop header region through which an
If
is split. Splitting anIf
through a loop header region is not intended and was disabled by JDK-8232539. However, the bailouts in the current code are not enough to prevent the split if optimization for this dying loop header node due to the following reasons:LoopNode
, yet, and we do not bail out at:jdk/src/hotspot/share/opto/ifnode.cpp
Line 119 in cd8783c
jdk/src/hotspot/share/opto/ifnode.cpp
Lines 143 to 148 in cd8783c
ConP
constant (dead path) and aCastPP
node which is also allowed as constant:jdk/src/hotspot/share/opto/ifnode.cpp
Lines 98 to 101 in cd8783c
jdk/src/hotspot/share/opto/ifnode.cpp
Lines 244 to 247 in cd8783c
These conditions let the split if optimization to be applied without a bailout. The
CastPP
node is a use of the phi and is thus rewired in the process. The problem now is that theCastPP
node is an input and output of the loop phi while being a constant to be merged:This lets the split if optimization to create a data loop by setting the input of the
CastPP
to itself.This scenario is rare and highly depends on the order in which IGVN processes the nodes. As a fix, I propose to extend the bailout checks for loop header regions to catch this edge case. The new check looks at all inputs of the region and bail out if only one path is non-top. This also avoids unnecessary splits through regions which are dying anyways.
Thanks,
Christian
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/4860/head:pull/4860
$ git checkout pull/4860
Update a local copy of the PR:
$ git checkout pull/4860
$ git pull https://git.openjdk.java.net/jdk pull/4860/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 4860
View PR using the GUI difftool:
$ git pr show -t 4860
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/4860.diff