-
Couldn't load subscription status.
- Fork 6.1k
8315920: C2: "control input must dominate current control" assert failure #15720
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
Changes from all commits
d5af551
e1e8cdf
f49d81f
58ed217
a084584
b0d9422
321a724
886f964
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2064,17 +2064,6 @@ CmpNode*PhaseIdealLoop::clone_bool(PhiNode* phi) { | |
| return (CmpNode*)cmp; | ||
| } | ||
|
|
||
| //------------------------------sink_use--------------------------------------- | ||
| // If 'use' was in the loop-exit block, it now needs to be sunk | ||
| // below the post-loop merge point. | ||
| void PhaseIdealLoop::sink_use( Node *use, Node *post_loop ) { | ||
| if (!use->is_CFG() && get_ctrl(use) == post_loop->in(2)) { | ||
| set_ctrl(use, post_loop); | ||
| for (DUIterator j = use->outs(); use->has_out(j); j++) | ||
| sink_use(use->out(j), post_loop); | ||
| } | ||
| } | ||
|
|
||
| void PhaseIdealLoop::clone_loop_handle_data_uses(Node* old, Node_List &old_new, | ||
| IdealLoopTree* loop, IdealLoopTree* outer_loop, | ||
| Node_List*& split_if_set, Node_List*& split_bool_set, | ||
|
|
@@ -2141,7 +2130,7 @@ void PhaseIdealLoop::clone_loop_handle_data_uses(Node* old, Node_List &old_new, | |
| while( use->in(idx) != old ) idx++; | ||
| Node *prev = use->is_CFG() ? use : get_ctrl(use); | ||
| assert(!loop->is_member(get_loop(prev)) && !outer_loop->is_member(get_loop(prev)), "" ); | ||
| Node *cfg = prev->_idx >= new_counter | ||
| Node* cfg = (prev->_idx >= new_counter && prev->is_Region()) | ||
| ? prev->in(2) | ||
| : idom(prev); | ||
| if( use->is_Phi() ) // Phi use is in prior block | ||
|
|
@@ -2165,7 +2154,7 @@ void PhaseIdealLoop::clone_loop_handle_data_uses(Node* old, Node_List &old_new, | |
|
|
||
| while(!outer_loop->is_member(get_loop(cfg))) { | ||
| prev = cfg; | ||
| cfg = cfg->_idx >= new_counter ? cfg->in(2) : idom(cfg); | ||
| cfg = (cfg->_idx >= new_counter && cfg->is_Region()) ? cfg->in(2) : idom(cfg); | ||
| } | ||
| // If the use occurs after merging several exits from the loop, then | ||
| // old value must have dominated all those exits. Since the same old | ||
|
|
@@ -2223,10 +2212,6 @@ void PhaseIdealLoop::clone_loop_handle_data_uses(Node* old, Node_List &old_new, | |
| if( hit ) // Go ahead and re-hash for hits. | ||
| _igvn.replace_node( use, hit ); | ||
| } | ||
|
|
||
| // If 'use' was in the loop-exit block, it now needs to be sunk | ||
| // below the post-loop merge point. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This comment needs to be moved to the new lazy-replace logic and cloning needs to be explained there as well. |
||
| sink_use( use, prev ); | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -2593,8 +2578,6 @@ void PhaseIdealLoop::fix_ctrl_uses(const Node_List& body, const IdealLoopTree* l | |
| // We need a Region to merge the exit from the peeled body and the | ||
| // exit from the old loop body. | ||
| RegionNode *r = new RegionNode(3); | ||
| // Map the old use to the new merge point | ||
| old_new.map( use->_idx, r ); | ||
| uint dd_r = MIN2(dom_depth(newuse), dom_depth(use)); | ||
| assert(dd_r >= dom_depth(dom_lca(newuse, use)), "" ); | ||
|
|
||
|
|
@@ -2630,12 +2613,24 @@ void PhaseIdealLoop::fix_ctrl_uses(const Node_List& body, const IdealLoopTree* l | |
| l -= uses_found; // we deleted 1 or more copies of this edge | ||
| } | ||
|
|
||
| assert(use->is_Proj(), "loop exit should be projection"); | ||
| // lazy_replace() below moves all nodes that are: | ||
| // - control dependent on the loop exit or | ||
| // - have control set to the loop exit | ||
| // below the post-loop merge point. lazy_replace() takes a dead control as first input. To make it | ||
| // possible to use it, the loop exit projection is cloned and becomes the new exit projection. The initial one | ||
| // becomes dead and is "replaced" by the region. | ||
| Node* use_clone = use->clone(); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe also add a comment here why you need to clone the node for |
||
| register_control(use_clone, use_loop, idom(use), dom_depth(use)); | ||
| // Now finish up 'r' | ||
| r->set_req(1, newuse); | ||
| r->set_req(2, use); | ||
| r->set_req(2, use_clone); | ||
| _igvn.register_new_node_with_optimizer(r); | ||
| set_loop(r, use_loop); | ||
| set_idom(r, (side_by_side_idom == nullptr) ? newuse->in(0) : side_by_side_idom, dd_r); | ||
| lazy_replace(use, r); | ||
| // Map the (cloned) old use to the new merge point | ||
| old_new.map(use_clone->_idx, r); | ||
| } // End of if a loop-exit test | ||
| } | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /* | ||
| * Copyright (c) 2023, Red Hat, Inc. All rights reserved. | ||
| * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
| * | ||
| * This code is free software; you can redistribute it and/or modify it | ||
| * under the terms of the GNU General Public License version 2 only, as | ||
| * published by the Free Software Foundation. | ||
| * | ||
| * This code is distributed in the hope that it will be useful, but WITHOUT | ||
| * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| * version 2 for more details (a copy is included in the LICENSE file that | ||
| * accompanied this code). | ||
| * | ||
| * You should have received a copy of the GNU General Public License version | ||
| * 2 along with this work; if not, write to the Free Software Foundation, | ||
| * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
| * | ||
| * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
| * or visit www.oracle.com if you need additional information or have any | ||
| * questions. | ||
| */ | ||
|
|
||
| /* | ||
| * @test | ||
| * bug 8315920 | ||
| * @summary C2: "control input must dominate current control" assert failure | ||
| * @requires vm.compiler2.enabled | ||
| * @run main/othervm -XX:-BackgroundCompilation -XX:-UseLoopPredicate -XX:-DoEscapeAnalysis TestBadControlAfterPreMainPost | ||
| */ | ||
|
|
||
| public class TestBadControlAfterPreMainPost { | ||
| private static volatile int volatileField; | ||
|
|
||
| public static void main(String[] args) { | ||
| int[] array2 = new int[100]; | ||
| for (int i = 0; i < 20_000; i++) { | ||
| test(1, array2); | ||
| } | ||
| } | ||
|
|
||
| private static int test(int j, int[] array2) { | ||
| int[] array = new int[10]; | ||
| array[j] = 42; | ||
| float f = 1; | ||
| for (int i = 0; i < 100; i++) { | ||
| for (int k = 0; k < 10; k++) { | ||
| } | ||
| f = f * 2; | ||
| } | ||
| int v = array[0]; | ||
| int i = 0; | ||
| do { | ||
| synchronized (new Object()) { | ||
| } | ||
| array2[i + v] = 42; | ||
| i++; | ||
| } while (i < 100); | ||
| return (int)f; | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment explaining that/why the
main_exitprojection changed.