Skip to content
This repository has been archived by the owner. It is now read-only.

8269752: C2: assert(false) failed: Bad graph detected in build_loop_late #247

Closed
wants to merge 3 commits into from

Conversation

rwestrel
Copy link
Contributor

@rwestrel rwestrel commented Jul 13, 2021

Some nodes are sunk out of the outer loop of vMeth(). A CastII node is
added on the exit path of the loop to pin the nodes out of the
loop. The dominating test of that CastII is:

if (i >= 132) {

so the CastII is updated with type int [132..]

The inner loop is eliminated, the outer loop is turned into a counted
loop, pre/main/post loops are created. The CastII control is now a
Region that merges paths from the pre/main/post loops. Its data input
is a Phi that merges the iv Phis of the 3 loops.

The loop body includes an early exit:

if (i2 != 0) {
vMeth_check_sum += i3;
return;
}

That test is guaranteed to be taken at the second iteration. As a
consequence, the backedge of the main loop is removed. What's left of
the main loop is still guarded by a an entry test that compares the iv
value out of the pre loop with an Opaque1 node. The CastII is now only
reachable through that test. The iv Phi of the pre loop constant folds
to a value that's not >= 132. As a consequence the CastII becomes
top. top propagates to other data node and as a consequence a Phi is
replaced by its only non top input. That causes the assert failure.

The CastII should not be reachable anymore once the iv Phi of the pre
loop has constant folded and the early exit in the main loop is always
taken. But because the test that guards the main loop uses an Opaque1,
it cannot constant fold. As a fix, I propose removing the Opaque1 once
the backedge of the main loop is removed. This allows the entry test
to constant fold. The Opaque1 has no purpose anymore given the loop
doesn't exist at this point.


Progress

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

Issue

  • JDK-8269752: C2: assert(false) failed: Bad graph detected in build_loop_late

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk17 pull/247/head:pull/247
$ git checkout pull/247

Update a local copy of the PR:
$ git checkout pull/247
$ git pull https://git.openjdk.java.net/jdk17 pull/247/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 247

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

Using diff file

Download this PR as a diff file:
https://git.openjdk.java.net/jdk17/pull/247.diff

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Jul 13, 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 label Jul 13, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Jul 13, 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 label Jul 13, 2021
@mlbridge
Copy link

@mlbridge mlbridge bot commented Jul 13, 2021

Webrevs

Copy link
Member

@chhagedorn chhagedorn left a comment

Nice analysis, that looks reasonable to me.

@@ -2933,7 +2933,7 @@ bool PhaseIdealLoop::multi_version_post_loops(IdealLoopTree *rce_loop, IdealLoop
}

// Find RCE'd post loop so that we can stage its guard.
if (!is_canonical_loop_entry(legacy_cl)) return multi_version_succeeded;
if (legacy_cl->is_canonical_loop_entry() == NULL) return multi_version_succeeded;
Copy link
Member

@chhagedorn chhagedorn Jul 13, 2021

Choose a reason for hiding this comment

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

Can you also add braces here?

Copy link
Contributor Author

@rwestrel rwestrel Jul 13, 2021

Choose a reason for hiding this comment

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

done.

@openjdk
Copy link

@openjdk openjdk bot commented Jul 13, 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:

8269752: C2: assert(false) failed: Bad graph detected in build_loop_late

Reviewed-by: chagedorn, 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 19 new commits pushed to the master branch:

  • e104ded: 8268635: Corrupt oop in ClassLoaderData
  • a32d2ee: 8269276: Additional tests for MessageDigest with different providers
  • 7b4d84c: 8270422: Test build/AbsPathsInImage.java fails after JDK-8259848
  • 72db09b: 8266313: (JEP-356) - RandomGenerator spec implementation requirements tightly coupled to JDK internal classes
  • 3bbd233: 8270075: SplittableRandom extends AbstractSplittableGenerator
  • 381bd62: 8266889: [macosx-aarch64] Crash with SIGBUS in MarkActivationClosure::do_code_blob during vmTestbase/nsk/jvmti/.../bi04t002 test run
  • 82c256e: 8259499: Handling type arguments from outer classes for inner class in javadoc
  • e5db9a9: 8268620: InfiniteLoopException test may fail on x86 platforms
  • 67273ae: 8269865: Async UL needs to handle ERANGE on exceeding SEM_VALUE_MAX
  • 0f54707: 8270056: Generated lambda class can not access protected static method of target class
  • ... and 9 more: https://git.openjdk.java.net/jdk17/compare/999ced03ccd58b216adf9a7bfb2646e511219e6c...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 label Jul 13, 2021
@rwestrel
Copy link
Contributor Author

@rwestrel rwestrel commented Jul 13, 2021

@chhagedorn thanks for the review

}
// compares can get conditionally flipped

int input = is_main_loop() ? 2 : 1;
bool res = cmpzm->in(input)->Opcode() == Op_Opaque1;
Copy link
Contributor

@vnkozlov vnkozlov Jul 13, 2021

Choose a reason for hiding this comment

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

You need to check input < cmpzm->in(input) and cmpzm->in(input) for NULL. There could be a "dead" path.

Copy link
Contributor Author

@rwestrel rwestrel Jul 15, 2021

Choose a reason for hiding this comment

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

Thanks for reviewing this. I updated the patch.

Copy link
Contributor

@vnkozlov vnkozlov left a comment

Good.

@rwestrel
Copy link
Contributor Author

@rwestrel rwestrel commented Jul 19, 2021

/integrate

@openjdk
Copy link

@openjdk openjdk bot commented Jul 19, 2021

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

  • 2dddcce: 8270858: Problem List java/awt/Window/MultiWindowApp/MultiWindowAppTest.java on Linux
  • 1350e2b: 8270556: Exclude security/infra/java/security/cert/CertPathValidator/certification/LetsEncryptCA
  • e104ded: 8268635: Corrupt oop in ClassLoaderData
  • a32d2ee: 8269276: Additional tests for MessageDigest with different providers
  • 7b4d84c: 8270422: Test build/AbsPathsInImage.java fails after JDK-8259848
  • 72db09b: 8266313: (JEP-356) - RandomGenerator spec implementation requirements tightly coupled to JDK internal classes
  • 3bbd233: 8270075: SplittableRandom extends AbstractSplittableGenerator
  • 381bd62: 8266889: [macosx-aarch64] Crash with SIGBUS in MarkActivationClosure::do_code_blob during vmTestbase/nsk/jvmti/.../bi04t002 test run
  • 82c256e: 8259499: Handling type arguments from outer classes for inner class in javadoc
  • e5db9a9: 8268620: InfiniteLoopException test may fail on x86 platforms
  • ... and 11 more: https://git.openjdk.java.net/jdk17/compare/999ced03ccd58b216adf9a7bfb2646e511219e6c...master

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot closed this Jul 19, 2021
@openjdk openjdk bot added integrated and removed ready rfr labels Jul 19, 2021
@openjdk
Copy link

@openjdk openjdk bot commented Jul 19, 2021

@rwestrel Pushed as commit c130451.

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
hotspot-compiler integrated
3 participants