Skip to content

Commit b1bab7f

Browse files
committed
8272570: C2: crash in PhaseCFG::global_code_motion
Backport-of: 0f428ca533627e758cdca599d4589f39c21e27b6
1 parent 58fe5e8 commit b1bab7f

File tree

2 files changed

+55
-2
lines changed

2 files changed

+55
-2
lines changed

src/hotspot/share/opto/lcm.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,7 +519,7 @@ Node* PhaseCFG::select(
519519
uint score = 0; // Bigger is better
520520
int idx = -1; // Index in worklist
521521
int cand_cnt = 0; // Candidate count
522-
bool block_size_threshold_ok = (block->number_of_nodes() > 10) ? true : false;
522+
bool block_size_threshold_ok = (recalc_pressure_nodes != NULL) && (block->number_of_nodes() > 10);
523523

524524
for( uint i=0; i<cnt; i++ ) { // Inspect entire worklist
525525
// Order in worklist is used to break ties.
@@ -933,7 +933,7 @@ bool PhaseCFG::schedule_local(Block* block, GrowableArray<int>& ready_cnt, Vecto
933933
return true;
934934
}
935935

936-
bool block_size_threshold_ok = (block->number_of_nodes() > 10) ? true : false;
936+
bool block_size_threshold_ok = (recalc_pressure_nodes != NULL) && (block->number_of_nodes() > 10);
937937

938938
// We track the uses of local definitions as input dependences so that
939939
// we know when a given instruction is avialable to be scheduled.
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
* Copyright (C) 2021 THL A29 Limited, a Tencent company. 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 8272570
28+
* @summary crash in PhaseCFG::global_code_motion
29+
* @requires vm.compiler2.enabled
30+
*
31+
* @run main/othervm -Xbatch TestGCMRecalcPressureNodes
32+
*/
33+
34+
public class TestGCMRecalcPressureNodes {
35+
public boolean bo0;
36+
public boolean bo1;
37+
public void foo() {
38+
int sh12 = 61;
39+
for (int i = 0; i < 50; i++) {
40+
sh12 *= 34;
41+
}
42+
Math.tan(1.0);
43+
bo0 = true;
44+
bo1 = true;
45+
}
46+
public static void main(String[] args) {
47+
TestGCMRecalcPressureNodes instance = new TestGCMRecalcPressureNodes();
48+
for (int i = 0; i < 50000; i++) {
49+
instance.foo();
50+
}
51+
}
52+
}
53+

0 commit comments

Comments
 (0)