Skip to content

Commit a39ed10

Browse files
committedAug 14, 2023
8314116: C2: assert(false) failed: malformed control flow after JDK-8305636
Reviewed-by: thartmann, kvn
1 parent 1de5bf1 commit a39ed10

File tree

2 files changed

+86
-1
lines changed

2 files changed

+86
-1
lines changed
 

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -2073,7 +2073,7 @@ void PhaseIdealLoop::initialize_assertion_predicates_for_peeled_loop(const Predi
20732073
Node* stride, IdealLoopTree* outer_loop,
20742074
const uint idx_before_clone,
20752075
const Node_List &old_new) {
2076-
if (!predicate_block->has_runtime_predicates()) {
2076+
if (!predicate_block->has_parse_predicate()) {
20772077
return;
20782078
}
20792079
Node* control = outer_loop_head->in(LoopNode::EntryControl);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
* Copyright (c) 2023, 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+
/*
26+
* @test
27+
* @bug 8314116
28+
* @summary We fail to remove a Template Assertion Predicate of a dying loop causing an assert. This will only be fixed
29+
* completely with JDK-8288981 and 8314116 just mitigates the problem.
30+
* @requires vm.compiler2.enabled
31+
* @run main/othervm -Xbatch -XX:-TieredCompilation
32+
* -XX:CompileCommand=compileonly,compiler.predicates.TestTemplateAssertionPredicateNotRemoved::*
33+
* compiler.predicates.TestTemplateAssertionPredicateNotRemoved
34+
* @run main/othervm -Xbatch -XX:-TieredCompilation -XX:LoopMaxUnroll=0
35+
* -XX:CompileCommand=compileonly,compiler.predicates.TestTemplateAssertionPredicateNotRemoved::*
36+
* compiler.predicates.TestTemplateAssertionPredicateNotRemoved
37+
*/
38+
39+
package compiler.predicates;
40+
41+
public class TestTemplateAssertionPredicateNotRemoved {
42+
static int[] iArrFld = new int[10];
43+
static long x;
44+
public static void main(String[] strArr) {
45+
for (int i = 0; i < 10000; i++) {
46+
test(i);
47+
test2(i);
48+
}
49+
}
50+
51+
static void test(int i1) {
52+
int i5, i6 = 8;
53+
54+
for (int i3 = 100; i3 > 3; --i3) {
55+
for (i5 = 1; i5 < 5; i5++) {
56+
switch (i1) {
57+
case 1:
58+
case 4:
59+
case 47:
60+
i6 = 4;
61+
}
62+
iArrFld[i5] = 23;
63+
}
64+
}
65+
}
66+
67+
static void test2(int i1) {
68+
int i3, i4 = 70, i5, i6 = 8, iArr1[] = new int[10];
69+
double d1 = 0.41007;
70+
for (i3 = 100; i3 > 3; --i3) {
71+
i4 += 3;
72+
for (i5 = 1; i5 < 5; i5++) {
73+
switch (i1) {
74+
case 1:
75+
case 4:
76+
case 47:
77+
i6 = 34;
78+
}
79+
x /= 34;
80+
iArrFld[i5] = 23;
81+
}
82+
}
83+
84+
}
85+
}

0 commit comments

Comments
 (0)
Please sign in to comment.