Skip to content
This repository was archived by the owner on Aug 27, 2022. It is now read-only.
/ lanai Public archive

Commit 9c99008

Browse files
committedMay 28, 2020
8245714: "Bad graph detected in build_loop_late" when loads are pinned on loop limit check uncommon branch
Reviewed-by: thartmann
1 parent 01cfedf commit 9c99008

File tree

2 files changed

+91
-7
lines changed

2 files changed

+91
-7
lines changed
 

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

+6-7
Original file line numberDiff line numberDiff line change
@@ -122,20 +122,19 @@ ProjNode* PhaseIdealLoop::create_new_if_for_predicate(ProjNode* cont_proj, Node*
122122
CallNode* call = rgn->as_Call();
123123
IdealLoopTree* loop = get_loop(call);
124124
rgn = new RegionNode(1);
125+
Node* uncommon_proj_orig = uncommon_proj;
126+
uncommon_proj = uncommon_proj->clone()->as_Proj();
127+
register_control(uncommon_proj, loop, iff);
125128
rgn->add_req(uncommon_proj);
126129
register_control(rgn, loop, uncommon_proj);
127130
_igvn.replace_input_of(call, 0, rgn);
128131
// When called from beautify_loops() idom is not constructed yet.
129132
if (_idom != NULL) {
130133
set_idom(call, rgn, dom_depth(rgn));
131134
}
132-
for (DUIterator_Fast imax, i = uncommon_proj->fast_outs(imax); i < imax; i++) {
133-
Node* n = uncommon_proj->fast_out(i);
134-
if (n->is_Load() || n->is_Store()) {
135-
_igvn.replace_input_of(n, 0, rgn);
136-
--i; --imax;
137-
}
138-
}
135+
// Move nodes pinned on the projection or whose control is set to
136+
// the projection to the region.
137+
lazy_replace(uncommon_proj_orig, rgn);
139138
} else {
140139
// Find region's edge corresponding to uncommon_proj
141140
for (; proj_index < rgn->req(); proj_index++)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
* Copyright (c) 2020, Red Hat, Inc. 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 8245714
27+
* @requires vm.compiler2.enabled
28+
* @summary "Bad graph detected in build_loop_late" when loads are pinned on loop limit check uncommon branch
29+
*
30+
* @run main/othervm -XX:-BackgroundCompilation -XX:ArrayCopyLoadStoreMaxElem=0 TestBadControlLoopLimitCheck
31+
*/
32+
33+
public class TestBadControlLoopLimitCheck {
34+
public static void main(String[] args) {
35+
int[] int_array = {0, 0};
36+
A[] obj_array = {new A(), new A()};
37+
for (int i = 0; i < 20_000; i++) {
38+
test1(int_array, 0, 10, false);
39+
test_helper(42);
40+
test2(obj_array, 0, 10, false);
41+
}
42+
}
43+
44+
private static int test1(int[] a, int start, int stop, boolean flag) {
45+
int[] b = new int[2]; // non escaping allocation
46+
System.arraycopy(a, 0, b, 0, 2); // optimized out
47+
int v = 1;
48+
int j = 0;
49+
for (; j < 10; j++);
50+
int inc = test_helper(j); // delay transformation to counted loop
51+
// loop limit check here has loads pinned on unc branch
52+
for (int i = start; i < stop; i += inc) {
53+
v *= 2;
54+
}
55+
if (flag) {
56+
v += b[0] + b[1];
57+
}
58+
return v;
59+
}
60+
61+
private static int test2(A[] a, int start, int stop, boolean flag) {
62+
A[] b = new A[2]; // non escaping allocation
63+
System.arraycopy(a, 0, b, 0, 2); // optimized out
64+
int v = 1;
65+
int j = 0;
66+
for (; j < 10; j++);
67+
int inc = test_helper(j); // delay transformation to counted loop
68+
// loop limit check here has loads pinned on unc branch
69+
for (int i = start; i < stop; i += inc) {
70+
v *= 2;
71+
}
72+
if (flag) {
73+
v += b[0].f + b[1].f;
74+
}
75+
return v;
76+
}
77+
78+
static class A {
79+
int f;
80+
}
81+
82+
static int test_helper(int j) {
83+
return j == 10 ? 10 : 1;
84+
}
85+
}

0 commit comments

Comments
 (0)
This repository has been archived.