Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
wants to merge 1 commit into from

Conversation

chhagedorn
Copy link
Member

@chhagedorn chhagedorn commented Aug 15, 2022

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 #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)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue

Issue

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

Reviewers

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

@bridgekeeper
Copy link

bridgekeeper bot commented Aug 15, 2022

👋 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.

@openjdk openjdk bot added the rfr Pull request is ready for review label Aug 15, 2022
@openjdk
Copy link

openjdk bot commented Aug 15, 2022

@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 openjdk bot added the hotspot-compiler hotspot-compiler-dev@openjdk.org label Aug 15, 2022
@mlbridge
Copy link

mlbridge bot commented Aug 15, 2022

Webrevs

Copy link
Member

@TobiHartmann TobiHartmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice analysis. The fix looks good to me.

@openjdk
Copy link

openjdk bot commented Aug 17, 2022

@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:

  • e8bc879: 8292443: Weak CAS VarHandle/Unsafe tests should test always-failing cases
  • 494d387: 8280152: AArch64: Reuse runtime call trampolines
  • 8b4e6ba: 8289332: Auto-generate ids for user-defined headings
  • 0fc9263: 8291828: Reduce runtime of java.util.stream microbenchmarks
  • e81210f: 8292352: 32-bit Windows build failures after JDK-8290059
  • f45b840: 8292384: Convert AdapterHandlerTable to ResourceHashtable
  • 0c67fba: 8289049: x86_32 build fails with GCC 11 due to newString646_US warning
  • bf7d6d3: 7132413: [macosx] closed/javax/swing/AbstractButton/5049549/bug5049549.java fails on MacOS
  • e230719: 8292448: Convert BitMapFragmentTable to ResourceHashtable
  • f75da22: 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 openjdk bot added the ready Pull request is ready to be integrated label Aug 17, 2022
@chhagedorn
Copy link
Member Author

Thanks Tobias for your review!

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good.

@chhagedorn
Copy link
Member Author

Thanks Vladimir for your review!

/integrate

@openjdk
Copy link

openjdk bot commented Aug 18, 2022

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

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

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Aug 18, 2022
@openjdk openjdk bot closed this Aug 18, 2022
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Aug 18, 2022
@openjdk
Copy link

openjdk bot commented Aug 18, 2022

@chhagedorn Pushed as commit 32d675c.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hotspot-compiler hotspot-compiler-dev@openjdk.org integrated Pull request has been integrated
3 participants