[lworld] RFR: 8265973: [lworld] C2 compilation fails due to infinite loop in PhaseIterGVN::optimize

Tobias Hartmann thartmann at openjdk.java.net
Mon May 3 14:54:38 UTC 2021


This is another instance of [JDK-8264586](https://bugs.openjdk.java.net/browse/JDK-8264586). The fix was not sufficient. The root cause is a subgraph that becomes unreachable from the bottom (but remains reachable from the top) after CCP removes a redundant null check. 

**Gory details:**
CCP has two phases. First, `PhaseCCP::analyze` visits all nodes and updates their types in `_types.map`. Then, `PhaseCCP::do_transform` only visits the nodes that are reachable from the bottom, updates their `bottom_type` and adds them to the IGVN worklist. During the second step, parts of the graph might be cut off (for example, due to a null-check that is found to be redundant) and the nodes of that subgraph are not visited. I.e., the following code is not executed:
https://github.com/openjdk/valhalla/blob/28a4ec0249fd86fe17f2b816c6f5f8eed31abfeb/src/hotspot/share/opto/phaseX.cpp#L1988-L1992

As a result, `LoadNodes` in the dead subgraph end up with types that are inconsistent with their bottom types. Since they are still reachable from the top, they will be processed by IGVN and then re-enqueued for IGVN indefinitely by this code:
https://github.com/openjdk/valhalla/blob/28a4ec0249fd86fe17f2b816c6f5f8eed31abfeb/src/hotspot/share/opto/memnode.cpp#L352-L358

The fix is to aggressively remove useless nodes after CCP. I'll consider upstreaming the fix after some bake time in Valhalla.

Thanks,
Tobias

-------------

Commit messages:
 - Some fixes
 - 8265973: [lworld] C2 compilation fails due to infinite loop in PhaseIterGVN::optimize

Changes: https://git.openjdk.java.net/valhalla/pull/397/files
 Webrev: https://webrevs.openjdk.java.net/?repo=valhalla&pr=397&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8265973
  Stats: 82 lines in 7 files changed: 64 ins; 8 del; 10 mod
  Patch: https://git.openjdk.java.net/valhalla/pull/397.diff
  Fetch: git fetch https://git.openjdk.java.net/valhalla pull/397/head:pull/397

PR: https://git.openjdk.java.net/valhalla/pull/397



More information about the valhalla-dev mailing list