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

Tobias Hartmann thartmann at openjdk.java.net
Wed May 5 09:20:27 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

Tobias Hartmann has updated the pull request incrementally with one additional commit since the last revision:

  Make sure safepoints are visited by PhaseCCP


  - all: https://git.openjdk.java.net/valhalla/pull/397/files
  - new: https://git.openjdk.java.net/valhalla/pull/397/files/710c485a..be8812c9

 - full: https://webrevs.openjdk.java.net/?repo=valhalla&pr=397&range=01
 - incr: https://webrevs.openjdk.java.net/?repo=valhalla&pr=397&range=00-01

  Stats: 26 lines in 3 files changed: 16 ins; 3 del; 7 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