RFR: 8309902: C2: assert(false) failed: Bad graph detected in build_loop_late after JDK-8305189
Roland Westrelin
roland at openjdk.org
Tue Jun 27 10:11:18 UTC 2023
The crash happens after the following steps:
1- pre/main/post loops are created with assert predicates above the main loop.
2- the main loop is peeled
3- as a consequence, the `OpaqueZeroTripGuard` for the main loop is removed
4- That allows narrowing of the type of the CastII that was added right
after the zero trip guard during pre/main/post loops creation
5- The CastII feeds into a range check CastII for the peeled iteration
that becomes top because the narrowed type of the first CastII
conflicts with the type recorded in the range check CastII.
6- The assert predicate that should fold to protect the range check
CastII doesn't because of the fix for JDK-8282592: on assert
predicate updates, the CastII at the zero trip guard is skipped. So
the range check CastII sees the narrowing of the type of the CastII
at the zero trip guard but the assert predicate doesn't.
The fix I propose is to revert that part of the change from
JDK-8282592 so both the range check CastII and the assert predicate
have the CastII at the zero trip guard as input and observe its type
updates. I went back to that bug and tried to reproduce the failure
again but couldn't. Reverting JDK-8281429 causes the bug to reproduce
again. I tried tweaking the test so the crash reproduces with
JDK-8281429 applied but couldn't.
This is caused by JDK-8305189 because step 3- happens because of
it. Before JDK-8305189, 3- happened after loop opts are over. I think
what happened then was that a template assertion predicate that was in
the process of having its `OpaqueLoopInit` and `OpaqueLoopStride`
removed constant folded so the crash wouldn't reproduce.
-------------
Commit messages:
- test & fix
Changes: https://git.openjdk.org/jdk/pull/14672/files
Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=14672&range=00
Issue: https://bugs.openjdk.org/browse/JDK-8309902
Stats: 64 lines in 2 files changed: 58 ins; 6 del; 0 mod
Patch: https://git.openjdk.org/jdk/pull/14672.diff
Fetch: git fetch https://git.openjdk.org/jdk.git pull/14672/head:pull/14672
PR: https://git.openjdk.org/jdk/pull/14672
More information about the hotspot-compiler-dev
mailing list