Skip to content

Commit 0ddf54e

Browse files
rwestreleme64
andcommittedJul 19, 2024
8335709: C2: assert(!loop->is_member(get_loop(useblock))) failed: must be outside loop
Co-authored-by: Emanuel Peter <epeter@openjdk.org> Reviewed-by: epeter, thartmann
1 parent 10982fe commit 0ddf54e

File tree

2 files changed

+61
-3
lines changed

2 files changed

+61
-3
lines changed
 

‎src/hotspot/share/opto/loopnode.cpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -5473,7 +5473,8 @@ int PhaseIdealLoop::build_loop_tree_impl( Node *n, int pre_order ) {
54735473

54745474
} else { // Else not a nested loop
54755475
if (!_loop_or_ctrl[m->_idx]) continue; // Dead code has no loop
5476-
l = get_loop(m); // Get previously determined loop
5476+
IdealLoopTree* m_loop = get_loop(m);
5477+
l = m_loop; // Get previously determined loop
54775478
// If successor is header of a loop (nest), move up-loop till it
54785479
// is a member of some outer enclosing loop. Since there are no
54795480
// shared headers (I've split them already) I only need to go up
@@ -5499,10 +5500,10 @@ int PhaseIdealLoop::build_loop_tree_impl( Node *n, int pre_order ) {
54995500
// Insert the NeverBranch between 'm' and it's control user.
55005501
NeverBranchNode *iff = new NeverBranchNode( m );
55015502
_igvn.register_new_node_with_optimizer(iff);
5502-
set_loop(iff, l);
5503+
set_loop(iff, m_loop);
55035504
Node *if_t = new CProjNode( iff, 0 );
55045505
_igvn.register_new_node_with_optimizer(if_t);
5505-
set_loop(if_t, l);
5506+
set_loop(if_t, m_loop);
55065507

55075508
Node* cfg = nullptr; // Find the One True Control User of m
55085509
for (DUIterator_Fast jmax, j = m->fast_outs(jmax); j < jmax; j++) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
/*
25+
* @test
26+
* @bug 8335709
27+
* @summary C2: assert(!loop->is_member(get_loop(useblock))) failed: must be outside loop
28+
* @library /test/lib
29+
* @run main/othervm -Xcomp -XX:CompileCommand=compileonly,InfiniteLoopBadControlNeverBranch::* InfiniteLoopBadControlNeverBranch
30+
*
31+
*/
32+
33+
34+
import jdk.test.lib.Utils;
35+
36+
public class InfiniteLoopBadControlNeverBranch {
37+
static int b;
38+
static short c;
39+
40+
public static void main(String[] args) throws InterruptedException {
41+
Thread thread = new Thread(() -> test());
42+
thread.setDaemon(true);
43+
thread.start();
44+
Thread.sleep(Utils.adjustTimeout(4000));
45+
}
46+
47+
static void test() {
48+
int i = 0;
49+
while (true) {
50+
if (i > 1) {
51+
b = 0;
52+
}
53+
c = (short) (b * 7);
54+
i++;
55+
}
56+
}
57+
}

0 commit comments

Comments
 (0)
Please sign in to comment.