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

8263189: C2: assert(!had_error) failed: bad dominance #3005

Closed
wants to merge 1 commit into from

Conversation

rwestrel
Copy link
Contributor

@rwestrel rwestrel commented Mar 15, 2021

A long counted loop has a Phi that depends on the iv
Phi. PhaseIdealLoop::is_counted_loop() is able to compute a narrow
type for the iv Phi (the loop only runs for a few iterations). As a
consequence the Phi that depends on the iv Phi also gets a narrow
type. When the long counted loop is transformed into a loop nest, even
though the long loop is known to run for only a few iterations, the
inner int counted loop that's created gets a wide type: the narrow
type of the long counted loop iv Phi should result in a narrow type
for the int counted loop iv Phi but doesn't. C2 then creates
pre/main/post loops for the inner int counted loop. It wouldn't have
proceeded with this step, had the number of iterations of the loop not
been lost. In the process, it creates Phi to merge the values from the
pre/main/post loop. Two of those Phis are for the dependent Phi, the
one that captured the narrow type. The type of one of the 2 Phis
becomes top because we get in an impossible situation where the loop
that's known to have very few iterations was cloned twice. One of the
just created Phi becomes top and dominance is broken.

The reason the iv Phi narrow type is lost at long loop transformation
time is because it's queried from the igvn but it was not yet recorded
with the igvn and instead set when the long counted loop was created
in the same loop pass. The fix for that is to query the type stored in
the Phi rather than from the igvn.

Now it's not right that we end up with a dependent Phi that captures
the narrow type (which happens at igvn time) before the loop is even
created (I said that happens in the same loop opts pass so igvn has
not had a chance to run). The reason for that is that the same loop is
transformed multiple times:

1- the long counted loop is created

2- the long counted loop is transformed to a loop nest with an inner
int counted loop. The outer loop is transformed back to a regular
loop.

3- the inner int counted loop is found to be empty and so optimized out

4- the long counted loop for the same loop is created again

5- a loop nest is created again

This looks wrong and I added code to prevent retransforming a long
counted loop.


Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change must be properly reviewed

Issue

  • JDK-8263189: C2: assert(!had_error) failed: bad dominance

Reviewers

Download

To checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/3005/head:pull/3005
$ git checkout pull/3005

To update a local copy of the PR:
$ git checkout pull/3005
$ git pull https://git.openjdk.java.net/jdk pull/3005/head

@bridgekeeper
Copy link

bridgekeeper bot commented Mar 15, 2021

👋 Welcome back roland! 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 Mar 15, 2021
@openjdk
Copy link

openjdk bot commented Mar 15, 2021

@rwestrel 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 Mar 15, 2021
@mlbridge
Copy link

mlbridge bot commented Mar 15, 2021

Webrevs

@vnkozlov
Copy link
Contributor

Changes seems fine.
But your statement that all transformations happened in "same loop opts pass" worries me too. Should we exit loop opts in between to allow IGVN to optimize graph?

@rwestrel
Copy link
Contributor Author

Changes seems fine.
But your statement that all transformations happened in "same loop opts pass" worries me too. Should we exit loop opts in between to allow IGVN to optimize graph?

Thanks for the review.
PhaseIdealLoop::is_counted_loop() has:

l->phi()->as_Phi()->set_type(l->phi()->Value(&_igvn));

for both int and long counted loops. I noticed (when I added this) that after the CountedLoop is built, we can narrow the iv Phi type but often, the loop is transformed in the same loop opts round (pre/main/post loops added) before igvn has a chance to run. When igvn finally runs, it can't narrow the iv Phi anymore.

Running igvn there for both int and long counted loops would seem quite disruptive.

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.

Okay.

@openjdk
Copy link

openjdk bot commented Mar 18, 2021

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

8263189: C2: assert(!had_error) failed: bad dominance

Reviewed-by: kvn, thartmann

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 164 new commits pushed to the master branch:

  • 0b03d04: 8167015: compiler/codecache/jmx/PoolsIndependenceTest.java timeout
  • df01b15: 8263977: GTK L&F: Cleanup duplicate checks in GTKStyle and GTKLookAndFeel
  • 57d8f1d: 8263985: BCEscapeAnalyzer::invoke checks target->is_loaded() twice
  • 4ef7c67: 8263979: Cleanup duplicate check in Unicode.contains
  • 289d48a: 8261673: Move javadoc for the lookup mechanism to module-info
  • 7b6efd3: 8263904: compiler/intrinsics/bmi/verifycode/BzhiTestI2L.java fails on x86_32
  • 036ae0e: 8225438: javax/net/ssl/TLSCommon/TestSessionLocalPrincipal.java failed with Read timed out
  • 5a51d70: 8247895: SHA1PRNGReseed.java is calling setSeed(0)
  • b2a52ea: 8263342: Add --connect option to jhsdb hsdb/clhsdb
  • 6b4c654: 8263776: [JVMCI] add helper to perform Java upcalls
  • ... and 154 more: https://git.openjdk.java.net/jdk/compare/a9b156d358b0436584a33f71abc00c9bed9d47a3...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 Mar 18, 2021
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. Looks good to me too.

@rwestrel
Copy link
Contributor Author

@TobiHartmann thanks for the review

@rwestrel
Copy link
Contributor Author

/integrate

@openjdk openjdk bot closed this Mar 23, 2021
@openjdk openjdk bot added integrated Pull request has been integrated and removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Mar 23, 2021
@openjdk
Copy link

openjdk bot commented Mar 23, 2021

@rwestrel Since your change was applied there have been 166 commits pushed to the master branch:

  • 7b81f8e: 8263915: runtime/cds/appcds/MismatchedPathTriggerMemoryRelease.java fails when UseCompressedClassPointers is off
  • 2da882c: 8262465: Very long compilation times and high memory consumption in C2 debug builds
  • 0b03d04: 8167015: compiler/codecache/jmx/PoolsIndependenceTest.java timeout
  • df01b15: 8263977: GTK L&F: Cleanup duplicate checks in GTKStyle and GTKLookAndFeel
  • 57d8f1d: 8263985: BCEscapeAnalyzer::invoke checks target->is_loaded() twice
  • 4ef7c67: 8263979: Cleanup duplicate check in Unicode.contains
  • 289d48a: 8261673: Move javadoc for the lookup mechanism to module-info
  • 7b6efd3: 8263904: compiler/intrinsics/bmi/verifycode/BzhiTestI2L.java fails on x86_32
  • 036ae0e: 8225438: javax/net/ssl/TLSCommon/TestSessionLocalPrincipal.java failed with Read timed out
  • 5a51d70: 8247895: SHA1PRNGReseed.java is calling setSeed(0)
  • ... and 156 more: https://git.openjdk.java.net/jdk/compare/a9b156d358b0436584a33f71abc00c9bed9d47a3...master

Your commit was automatically rebased without conflicts.

Pushed as commit fd3a33a.

💡 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