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

8279837: C2: assert(is_Loop()) failed: invalid node class: Region #94

Closed
wants to merge 1 commit into from

Conversation

chhagedorn
Copy link
Member

@chhagedorn chhagedorn commented Jan 11, 2022

In the test case, we are attempting to apply iteration_split_impl() to a loop head which is a RegionNode and not a LoopNode. We then fail with an assertion when attempting to cast it.

This is quite an edge case. build_loop_tree() is initially adding a NeverBranch to an infinite inner loop. Afterwards, beautify_loop() makes progress on some other loop nest where the inner and outer loop share the same loop head. As a result, build_loop_tree() is called again:

if( _ltree_root->_child->beautify_loops( this ) ) {
// Re-build loop tree!
_ltree_root->_child = NULL;
_nodes.clear();
reallocate_preorders();
build_loop_tree();

Through Root -> Halt -> CProj -> NeverBranch, the infinite loop is now reachable and is built as child of _ltree_root. However, the Region is not yet a Loop node. This will only happen in the next iteration of loop opts when beautify_loop() is called again. We then fail with the assertion assuming that loop tree head nodes are always LoopNodes. Some more details can be found in the comments of the test.

The fix is straight forward to bail out of iteration_split_impl() for non-LoopNodes. We already do a similar bailout in other optimizations like loop predication:

if (!loop->_head->is_Loop()) {
// Could be a simple region when irreducible loops are present.
return false;
}

Thanks,
Christian


Progress

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

Issue

  • JDK-8279837: C2: assert(is_Loop()) failed: invalid node class: Region

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 94

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

Using diff file

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

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented Jan 11, 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 label Jan 11, 2022
@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 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 label Jan 11, 2022
@mlbridge
Copy link

@mlbridge mlbridge bot commented Jan 11, 2022

Webrevs

Copy link

@vnkozlov vnkozlov left a comment

Good. This reminds me similar fix I did in JDK 11u: JDK-8268360

@openjdk
Copy link

@openjdk openjdk bot commented Jan 11, 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:

8279837: C2: assert(is_Loop()) failed: invalid node class: Region

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 no new commits pushed to the master branch. If another commit should be pushed before you perform the /integrate command, your PR will be automatically rebased. If you prefer to avoid any potential 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 Jan 11, 2022
@chhagedorn
Copy link
Member Author

@chhagedorn chhagedorn commented Jan 12, 2022

Yes, that looks very similar. Thanks Vladimir for your review!

Copy link
Member

@TobiHartmann TobiHartmann left a comment

Looks good to me.

@chhagedorn
Copy link
Member Author

@chhagedorn chhagedorn commented Jan 12, 2022

Thanks Tobias for your review!

@chhagedorn
Copy link
Member Author

@chhagedorn chhagedorn commented Jan 13, 2022

/integrate

@openjdk
Copy link

@openjdk openjdk bot commented Jan 13, 2022

Going to push as commit 65eb066.

@openjdk openjdk bot added the integrated label Jan 13, 2022
@openjdk openjdk bot closed this Jan 13, 2022
@openjdk openjdk bot removed ready rfr labels Jan 13, 2022
@openjdk
Copy link

@openjdk openjdk bot commented Jan 13, 2022

@chhagedorn Pushed as commit 65eb066.

💡 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