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

8307927: C2: "malformed control flow" with irreducible loop #14522

Closed
wants to merge 3 commits into from

Conversation

rwestrel
Copy link
Contributor

@rwestrel rwestrel commented Jun 16, 2023

The test contains a loop nest with 2 loops. The outer loop is an
irreducible loop. The safepoint for that loop is also in the inner
loop. Because IdealLoopTree::check_safepts() ignores irreducible
loops, that safepoint is not marked as being required and is
eliminated from the inner loop. The inner loop is then optimized out
and the outer loop becomes an infinite loop with no safepoint (a
single node loop). That, in turn, causes the loop to be eliminated
because it has not use and the assert fires.

The fix I propose is to make IdealLoopTree::check_safepts() work
with irreducible loops. I think
IdealLoopTree::allpaths_check_safepts() can be used for that. When
working on this I wondered if that method could be called with a loop
whose head has more than 3 inputs. I couldn't write a test case with
an irreducible loop whose head had more than 3 inputs but I added an
assert in the method and ran some testing. That assert fired so I also
propose to tweak the method so it's robust in that case.


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-8307927: C2: "malformed control flow" with irreducible loop (Bug - P4)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 14522

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

Using diff file

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

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 16, 2023

👋 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 Jun 16, 2023
@openjdk
Copy link

openjdk bot commented Jun 16, 2023

@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 Jun 16, 2023
@mlbridge
Copy link

mlbridge bot commented Jun 16, 2023

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.

Looks reasonable to me. All tests passed.

@eme64 Please have a look as well.

@openjdk
Copy link

openjdk bot commented Jun 23, 2023

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

8307927: C2: "malformed control flow" with irreducible loop

Reviewed-by: thartmann, epeter

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

  • be64d3a: 8310299: C2: 8275201 broke constant folding of array store check in some cases
  • b2eae16: 8295191: IR framework timeout options expect ms instead of s
  • af319d9: 8311064: Windows builds fail without precompiled headers after JDK-8310728
  • cbf418a: 8311020: Typo cleanup in Classfile API
  • f4b900b: 8310902: (fc) FileChannel.transferXXX async close and interrupt issues
  • cf8d706: 8308463: Refactor regenerated class handling in lambdaFormInvokers.cpp
  • 6f58ab2: 8301569: jmod list option and jimage list --help not interpreted correctly on turkish locale
  • 8f5a384: 8311032: Empty value for java.protocol.handler.pkgs system property can lead to unnecessary classloading attempts of protocol handlers
  • ded1370: 8309811: BytecodePrinter cannot handle unlinked classes
  • 02b17d7: 8310264: In PhaseChaitin::Split defs and phis are leaked
  • ... and 77 more: https://git.openjdk.org/jdk/compare/7628da200833d0d26215a91afdd1bf7fc110da1d...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 Jun 23, 2023
@@ -3514,9 +3514,9 @@ bool IdealLoopTree::beautify_loops( PhaseIdealLoop *phase ) {
// encountered. Helper for check_safepts.
void IdealLoopTree::allpaths_check_safepts(VectorSet &visited, Node_List &stack) {
Copy link
Contributor

Choose a reason for hiding this comment

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

@rwestrel you should update the description here. Suggestion:

Allpaths backwards scan. Starting at the head, traversing all backedges, and the body. Terminating each path at first safepoint encountered.  Helper for check_safepts.

Copy link
Contributor

Choose a reason for hiding this comment

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

Also the line above is not accurate enough anymore:
_required_safept->push(n); // save the one closest to the tail

For one: could there not be multiple such SafePoints? If so: what does it mean to take "the closest"? And we may have multiple backedges / tails, now that we allow irreducible loops.

Copy link
Contributor

Choose a reason for hiding this comment

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

Other than that the fix looks reasonable to me, thanks for the fix @rwestrel !

@rwestrel
Copy link
Contributor Author

@eme64 thanks for reviewing this (and making suggestions). Does the updated change look ok?

Copy link
Contributor

@eme64 eme64 left a comment

Choose a reason for hiding this comment

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

Thanks for the changes @rwestrel , looks good now!

@rwestrel
Copy link
Contributor Author

@TobiHartmann @eme64 thanks for the reviews.

@rwestrel
Copy link
Contributor Author

/integrate

@openjdk
Copy link

openjdk bot commented Jun 29, 2023

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

  • be64d3a: 8310299: C2: 8275201 broke constant folding of array store check in some cases
  • b2eae16: 8295191: IR framework timeout options expect ms instead of s
  • af319d9: 8311064: Windows builds fail without precompiled headers after JDK-8310728
  • cbf418a: 8311020: Typo cleanup in Classfile API
  • f4b900b: 8310902: (fc) FileChannel.transferXXX async close and interrupt issues
  • cf8d706: 8308463: Refactor regenerated class handling in lambdaFormInvokers.cpp
  • 6f58ab2: 8301569: jmod list option and jimage list --help not interpreted correctly on turkish locale
  • 8f5a384: 8311032: Empty value for java.protocol.handler.pkgs system property can lead to unnecessary classloading attempts of protocol handlers
  • ded1370: 8309811: BytecodePrinter cannot handle unlinked classes
  • 02b17d7: 8310264: In PhaseChaitin::Split defs and phis are leaked
  • ... and 77 more: https://git.openjdk.org/jdk/compare/7628da200833d0d26215a91afdd1bf7fc110da1d...master

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Jun 29, 2023

@rwestrel Pushed as commit 690d626.

💡 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
Development

Successfully merging this pull request may close these issues.

3 participants