jdk icon indicating copy to clipboard operation
jdk copied to clipboard

8291775: C2: assert(r != __null && r->is_Region()) failed: this phi must have a region

Open chhagedorn opened this issue 3 years ago • 3 comments
trafficstars

JDK-8271341 fixed a case for string opts where a diamond Region/If in the middle of a chain of calls that are optimized out is not folded away correctly in IGVN, leading to a broken graph. The problem in the test case of JDK-8271341 was the following:

One of the inputs of the Cmp nodes of the If is replaced by top (the data projection of the removed call into the Cmp node). During IGVN, top propagated too quickly to the If before the Region/If diamond could be folded away. As a result, the control flow below the If became dead. The fix was to eagerly fold the Region/If diamond in string opts by replacing the Region by the control input of the If (see https://github.com/openjdk/jdk/pull/4944):

Screenshot from 2022-08-15 11-24-31

Replaced 396 Region by control input of If (330 IfTrue):

Screenshot from 2022-08-15 11-24-47

The reason why we can rewire the phis to a non-region during string opts is because all phis are dead and will be removed. In the testcase of JDK-8271341, this is done in PhaseRemoveUseless because the data 424 Phi has no users after string opts anymore.

However, in the test case of this bug (actually the same test case but run with -XX:+AlwaysIncrementalInline), we have an additional memory phi which is actually dead but not removed by PhaseRemoveUseless because it still has other users at that point. The memory phi would eventually be removed during IGVN but the problem is that it is unexpected to process a phi with a non-region control input and we fail with the assertion in PhiNode::Ideal().

The fix I propose is to not replace the Region node with the control input of the If as in JDK-8271341 but instead setting the boolean input of the If node to a constant (doesn't matter if 0 or 1 since the phis are dead anyways). If we then process the If or IfTrue/IfFalse before the Region in IGVN, we simply fold the node. This allows IGVN to safely remove a diamond Region/If without interference of top from string opts. The memory phi is eventually removed during IGVN.

Thanks, Christian


Progress

  • [ ] Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • [x] Change must not contain extraneous whitespace
  • [x] Commit message must refer to an issue

Issue

  • JDK-8291775: C2: assert(r != __null && r->is_Region()) failed: this phi must have a region

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/9878/head:pull/9878
$ git checkout pull/9878

Update a local copy of the PR:
$ git checkout pull/9878
$ git pull https://git.openjdk.org/jdk pull/9878/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 9878

View PR using the GUI difftool:
$ git pr show -t 9878

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/9878.diff

chhagedorn avatar Aug 15 '22 12:08 chhagedorn

:wave: Welcome back chagedorn! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

bridgekeeper[bot] avatar Aug 15 '22 12:08 bridgekeeper[bot]

@chhagedorn The following label will be automatically applied to this pull request:

  • hotspot-compiler

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command.

openjdk[bot] avatar Aug 15 '22 12:08 openjdk[bot]

Webrevs

mlbridge[bot] avatar Aug 15 '22 12:08 mlbridge[bot]

@chhagedorn This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8291775: C2: assert(r != __null && r->is_Region()) failed: this phi must have a region

Reviewed-by: thartmann, kvn

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 112 new commits pushed to the master branch:

  • e8bc87956abc92851de8694c56a78f6ecc546cbd: 8292443: Weak CAS VarHandle/Unsafe tests should test always-failing cases
  • 494d3873b1d0f7e3ca0a063b44362e7242298dec: 8280152: AArch64: Reuse runtime call trampolines
  • 8b4e6ba01ffef77d5f1b9a9aa3e978f4da431836: 8289332: Auto-generate ids for user-defined headings
  • 0fc92637d297d9a1281df33089975bd6d5fdf809: 8291828: Reduce runtime of java.util.stream microbenchmarks
  • e81210f5fe03ea3dc9c9fb0dba2be79e1dcc03bc: 8292352: 32-bit Windows build failures after JDK-8290059
  • f45b8408a0e66aee22a6ac60e3f24dfc8ac104e5: 8292384: Convert AdapterHandlerTable to ResourceHashtable
  • 0c67fba11f444cc3739f66c8a2d57564b5dcca72: 8289049: x86_32 build fails with GCC 11 due to newString646_US warning
  • bf7d6d3a0f947ab4a30f27bce6650798289cc7fd: 7132413: [macosx] closed/javax/swing/AbstractButton/5049549/bug5049549.java fails on MacOS
  • e230719ad3cc9e70511d7baa6338bb77cd038139: 8292448: Convert BitMapFragmentTable to ResourceHashtable
  • f75da2235ab7e33927729fa060ec4d86fdb0240f: 8292395: [testbug] VectorGatherScatterTest.java fails on SVE with -XX:MaxVectorSize=8 after JDK-8288397
  • ... and 102 more: https://git.openjdk.org/jdk/compare/20123ea4de702ccbaf4c500ff7a1000ca7ee9c90...master

As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

openjdk[bot] avatar Aug 17 '22 07:08 openjdk[bot]

Thanks Tobias for your review!

chhagedorn avatar Aug 17 '22 11:08 chhagedorn

Thanks Vladimir for your review!

/integrate

chhagedorn avatar Aug 18 '22 07:08 chhagedorn

Going to push as commit 32d675ca607d341ca3428efc32e212701775e3c6. Since your change was applied there have been 113 commits pushed to the master branch:

  • 0d96546ab93600f17877e5db2770e4125916bcda: 8292054: Test runtime/posixSig/TestPosixSig.java fails with 'Test failed, bad output.'
  • e8bc87956abc92851de8694c56a78f6ecc546cbd: 8292443: Weak CAS VarHandle/Unsafe tests should test always-failing cases
  • 494d3873b1d0f7e3ca0a063b44362e7242298dec: 8280152: AArch64: Reuse runtime call trampolines
  • 8b4e6ba01ffef77d5f1b9a9aa3e978f4da431836: 8289332: Auto-generate ids for user-defined headings
  • 0fc92637d297d9a1281df33089975bd6d5fdf809: 8291828: Reduce runtime of java.util.stream microbenchmarks
  • e81210f5fe03ea3dc9c9fb0dba2be79e1dcc03bc: 8292352: 32-bit Windows build failures after JDK-8290059
  • f45b8408a0e66aee22a6ac60e3f24dfc8ac104e5: 8292384: Convert AdapterHandlerTable to ResourceHashtable
  • 0c67fba11f444cc3739f66c8a2d57564b5dcca72: 8289049: x86_32 build fails with GCC 11 due to newString646_US warning
  • bf7d6d3a0f947ab4a30f27bce6650798289cc7fd: 7132413: [macosx] closed/javax/swing/AbstractButton/5049549/bug5049549.java fails on MacOS
  • e230719ad3cc9e70511d7baa6338bb77cd038139: 8292448: Convert BitMapFragmentTable to ResourceHashtable
  • ... and 103 more: https://git.openjdk.org/jdk/compare/20123ea4de702ccbaf4c500ff7a1000ca7ee9c90...master

Your commit was automatically rebased without conflicts.

openjdk[bot] avatar Aug 18 '22 07:08 openjdk[bot]

@chhagedorn Pushed as commit 32d675ca607d341ca3428efc32e212701775e3c6.

:bulb: You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

openjdk[bot] avatar Aug 18 '22 07:08 openjdk[bot]