RFR: 8335220: C2: Missing check for Opaque4 node in EscapeAnalysis

Vladimir Kozlov kvn at openjdk.org
Thu Jun 27 05:38:19 UTC 2024


While testing Leyden Early Release the problem was found in C2 EscapeAnalysis, in new code which handles allocations merge. `ConnectionGraph:: can_reduce_check_users()` have incomplete checks which missed case with `Opaque4` node between `If` and `Bool` nodes. As result we hit assert in `ConnectionGraph::specialize_cmp()` when trying to access inputs of `Cmp` node

Node* curr_cmp = curr_ctrl->in(0)->in(1)->in(1); // true/false -> if -> bool -> cmp
con = curr_cmp->in(1)->is_Con() ? curr_cmp->in(1) : curr_cmp->in(2);


This code was introduce for ReduceAllocationMerges optimization [JDK-8316991](https://bugs.openjdk.org/browse/JDK-8316991) in JDK-23. There was followup fix [JDK-8330853](https://bugs.openjdk.org/browse/JDK-8330853) to add more checks but it missed this case.

I added more strict check in `can_reduce_check_users()` to catch such cases. And added asserts in `specialize_cmp()` to verify expected nodes.

Tested tier1-3.hs-stress,hs-xcomp

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

Commit messages:
 - 8335220: C2: Missing check for Opaque4 node in EscapeAnalysis

Changes: https://git.openjdk.org/jdk/pull/19921/files
  Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=19921&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8335220
  Stats: 19 lines in 1 file changed: 10 ins; 3 del; 6 mod
  Patch: https://git.openjdk.org/jdk/pull/19921.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/19921/head:pull/19921

PR: https://git.openjdk.org/jdk/pull/19921


More information about the hotspot-compiler-dev mailing list