[12] RFR(S): 8208275: C2 crash in Node::add_req(Node*)
Tobias Hartmann
tobias.hartmann at oracle.com
Tue Aug 14 11:56:15 UTC 2018
Hi,
please review the following patch:
https://bugs.openjdk.java.net/browse/JDK-8208275
http://cr.openjdk.java.net/~thartmann/8208275/webrev.00/
A loop with only one iteration is strip mined and then processed by
IdealLoopTree::policy_do_one_iteration_loop() which replaces the tripcount phi such that the
backedge becomes dead and the loop goes away. Usually, the code in RegionNode::Ideal [1] takes care
of removing the OuterStripMinedLoop as well but in the failing case the split-if optimization is
invoked first (it depends on the order in which igvn processes nodes in the worklist). Split-if now
performs its magic and then removes the CountedLoop without removing the OuterStripMinedLoop [2].
As a result, the graph contains an OuterStripMinedLoop without the corresponding CountedLoop. This
triggers various asserts and crashes (see bug comments for all failure modes).
The straight forward fix is to remove the outer loop in policy_do_one_iteration_loop() similar to
what we do in PhaseIdealLoop::intrinsify_fill(). I was wondering if other optimizations could
trigger the same problem but came to the conclusion that split-if would bail out because either:
- the tripcount phi was removed and the counted loop backedge is already top [3] or
- the tripcount phi is still there and used by the AddI for increment [4]
The policy_do_one_iteration_loop() case is special because the tripcount phi is directly removed but
the backedge is not (yet) top so split-if does not notice that the loop is dead.
An alternative would be to bail out of the split-if optimization if the region is a strip mined loop
or remove the outer strip mined loop if the region is removed.
The bug was originally reported with a confidential customer application but I was able to extract a
simple regression test that triggers all failure modes.
Thanks,
Tobias
[1] http://hg.openjdk.java.net/jdk/jdk/file/38ec0cea438e/src/hotspot/share/opto/cfgnode.cpp#l575
[2] http://hg.openjdk.java.net/jdk/jdk/file/38ec0cea438e/src/hotspot/share/opto/ifnode.cpp#l469
[3] http://hg.openjdk.java.net/jdk/jdk/file/38ec0cea438e/src/hotspot/share/opto/ifnode.cpp#l120
[4] http://hg.openjdk.java.net/jdk/jdk/file/38ec0cea438e/src/hotspot/share/opto/ifnode.cpp#l193
More information about the hotspot-compiler-dev
mailing list