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

8275330: C2: assert(n->is_Root() || n->is_Region() || n->is_Phi() || n->is_MachMerge() || def_block->dominates(block)) failed: uses must be dominated by definitions #6429

Closed
wants to merge 3 commits into from

Conversation

rwestrel
Copy link
Contributor

@rwestrel rwestrel commented Nov 17, 2021

This is similar to previous bugs where:

  • a cast/conv node captures a narrow type in a loop body because of a
    range check,

  • the range check is optimized out of the loop, pre/main/post loop are
    created

  • overunrolling causes the main loop to become unreachable (the range
    check, if still in the main loop, would fail), the cast transforms to
    top but c2 can't optimize the loop out

This was fixed by adding predicates above the main loop. With this
particular bug, the cast node is in the post loop. The fix I propose
is to also add predicates above the post loop. There are a few
locations in the code that cause a post loop to be added: either the
initial post loop or some other post loops for vectorization
support. I think the new predicates are needed in a all cases. To be
able to add predicates at these different points in the optimization
process, the new predicates are copied from the main loop predicates.

I also delayed folding of Opaque4 nodes to macro expansion rather than
post loop opts igvn. The reason for that is that I believe there's a
risk that an Opaque4 is removed (that is replaced by its input 2)
before its input 1 has a chance to constant fold. That wouldn't happen
with a debug build because we leave the tests in (that is replace the
Opaque4 node by its input 1) so that corner case is not properly
tested currently. The reason for leaving the tests in was to sanity
check that the tests are indeed correct.


Progress

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

Issue

  • JDK-8275330: C2: assert(n->is_Root() || n->is_Region() || n->is_Phi() || n->is_MachMerge() || def_block->dominates(block)) failed: uses must be dominated by definitions

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 6429

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

Using diff file

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

@bridgekeeper
Copy link

bridgekeeper bot commented Nov 17, 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 Nov 17, 2021
@openjdk
Copy link

openjdk bot commented Nov 17, 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 Nov 17, 2021
@mlbridge
Copy link

mlbridge bot commented Nov 17, 2021

Webrevs

Copy link
Member

@TobiHartmann TobiHartmann left a comment

That looks good to me.

prev_proj = clone_skeleton_predicate_for_main_or_post_loop(iff, init, stride, ctrl, proj, post_loop_entry,
post_loop, prev_proj);
assert(!skeleton_predicate_has_opaque(prev_proj->in(0)->as_If()), "unexpected");
}
Copy link
Member

@TobiHartmann TobiHartmann Nov 23, 2021

Choose a reason for hiding this comment

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

Intendation is wrong.

@openjdk
Copy link

openjdk bot commented Nov 23, 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:

8275330: C2:  assert(n->is_Root() || n->is_Region() || n->is_Phi() || n->is_MachMerge() || def_block->dominates(block)) failed: uses must be dominated by definitions

Reviewed-by: thartmann, chagedorn

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

  • 00a6238: 8277508: need to check has_predicated_vectors before calling scalable_predicate_reg_slots
  • 3383c0d: 8277659: [TESTBUG] Microbenchmark ThreadOnSpinWaitProducerConsumer.java hangs
  • 7e54d06: 8277165: jdeps --multi-release --print-module-deps fails if module-info.class in different versioned directories
  • eb4d886: 8277504: Use String.stripTrailing instead of hand-crafted method in SwingUtilities2
  • 9879920: 8277825: Remove unused ReferenceProcessorPhaseTimes::_sub_phases_total_time_ms
  • f788834: 8277786: G1: Rename log2_card_region_per_heap_region used in G1CardSet

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
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 Nov 23, 2021
Copy link
Member

@chhagedorn chhagedorn left a comment

Otherwise, the fix looks reasonable to me! When I was fixing related bugs before, I found myself wondering if the post loop does not need these predicates as well - turns out now it does.

@@ -1544,7 +1545,8 @@ void PhaseIdealLoop::insert_pre_post_loops(IdealLoopTree *loop, Node_List &old_n
// Add the post loop
const uint idx_before_pre_post = Compile::current()->unique();
CountedLoopNode *post_head = NULL;
Node *main_exit = insert_post_loop(loop, old_new, main_head, main_end, incr, limit, post_head);
Node* post_incr = incr;
Node *main_exit = insert_post_loop(loop, old_new, main_head, main_end, post_incr, limit, post_head);
Copy link
Member

@chhagedorn chhagedorn Nov 23, 2021

Choose a reason for hiding this comment

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

Could also be updated: Node *main_exit -> Node* main_exit.

@@ -1968,6 +1975,34 @@ void PhaseIdealLoop::update_main_loop_skeleton_predicates(Node* ctrl, CountedLoo
}
}

void PhaseIdealLoop::insert_post_loop_skeleton_predicates(LoopNode* main_loop_head, CountedLoopNode* post_loop_head, Node* init, Node* stride) {
Copy link
Member

@chhagedorn chhagedorn Nov 23, 2021

Choose a reason for hiding this comment

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

Maybe this could be renamed to copy_skeleton_predicates_to_post_loop() to be consistent with the method copy_skeleton_predicates_to_main_loop()?

@@ -1915,6 +1920,7 @@ Node *PhaseIdealLoop::insert_post_loop(IdealLoopTree *loop, Node_List &old_new,
// CastII for the new post loop:
Node* castii = cast_incr_before_loop(zer_opaq->in(1), zer_taken, post_head);
assert(castii != NULL, "no castII inserted");
incr = castii;
Copy link
Member

@chhagedorn chhagedorn Nov 23, 2021

Choose a reason for hiding this comment

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

You could directly assign incr on L1921 instead of using the additional castii variable.

@rwestrel
Copy link
Contributor Author

rwestrel commented Nov 26, 2021

@TobiHartmann @chhagedorn Thanks for the reviews. All comment should be addressed in the updated change.

Copy link
Member

@chhagedorn chhagedorn left a comment

Thanks for doing the updates, looks good!

Copy link
Member

@TobiHartmann TobiHartmann left a comment

Looks good. All testing passed.

@rwestrel
Copy link
Contributor Author

rwestrel commented Nov 26, 2021

/integrate

@openjdk
Copy link

openjdk bot commented Nov 26, 2021

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

  • 99e4bda: 8277417: C1 LIR instruction for load-klass
  • 00a6238: 8277508: need to check has_predicated_vectors before calling scalable_predicate_reg_slots
  • 3383c0d: 8277659: [TESTBUG] Microbenchmark ThreadOnSpinWaitProducerConsumer.java hangs
  • 7e54d06: 8277165: jdeps --multi-release --print-module-deps fails if module-info.class in different versioned directories
  • eb4d886: 8277504: Use String.stripTrailing instead of hand-crafted method in SwingUtilities2
  • 9879920: 8277825: Remove unused ReferenceProcessorPhaseTimes::_sub_phases_total_time_ms
  • f788834: 8277786: G1: Rename log2_card_region_per_heap_region used in G1CardSet

Your commit was automatically rebased without conflicts.

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

openjdk bot commented Nov 26, 2021

@rwestrel Pushed as commit 3e798dd.

💡 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 integrated
3 participants