Mon, 23 Mar 2020 19:52:34 +0800
8240576: JVM crashes after transformation in C2 IdealLoopTree::merge_many_backedges
Reviewed-by: kvn
Contributed-by: hedongbo@huawei.com
src/share/vm/opto/loopnode.cpp | file | annotate | diff | comparison | revisions | |
test/compiler/loopopts/TestBeautifyLoops.java | file | annotate | diff | comparison | revisions |
1.1 --- a/src/share/vm/opto/loopnode.cpp Fri Apr 24 04:23:06 2020 +0100 1.2 +++ b/src/share/vm/opto/loopnode.cpp Mon Mar 23 19:52:34 2020 +0800 1.3 @@ -1538,7 +1538,7 @@ 1.4 // If I am a shared header (multiple backedges), peel off the many 1.5 // backedges into a private merge point and use the merge point as 1.6 // the one true backedge. 1.7 - if( _head->req() > 3 ) { 1.8 + if (_head->req() > 3 && !_irreducible) { 1.9 // Merge the many backedges into a single backedge but leave 1.10 // the hottest backedge as separate edge for the following peel. 1.11 merge_many_backedges( phase );
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/test/compiler/loopopts/TestBeautifyLoops.java Mon Mar 23 19:52:34 2020 +0800 2.3 @@ -0,0 +1,61 @@ 2.4 +/* 2.5 + * Copyright (c) 2020, Huawei Technologies Co. Ltd. All rights reserved. 2.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 2.7 + * 2.8 + * This code is free software; you can redistribute it and/or modify it 2.9 + * under the terms of the GNU General Public License version 2 only, as 2.10 + * published by the Free Software Foundation. 2.11 + * 2.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 2.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 2.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 2.15 + * version 2 for more details (a copy is included in the LICENSE file that 2.16 + * accompanied this code). 2.17 + * 2.18 + * You should have received a copy of the GNU General Public License version 2.19 + * 2 along with this work; if not, write to the Free Software Foundation, 2.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2.21 + * 2.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2.23 + * or visit www.oracle.com if you need additional information or have any 2.24 + * questions. 2.25 + */ 2.26 + 2.27 +/** 2.28 + * @test 2.29 + * @bug 8240576 2.30 + * @summary JVM crashes after transformation in C2 IdealLoopTree::merge_many_backedges 2.31 + * 2.32 + * @run main/othervm -XX:-TieredCompilation -XX:-BackgroundCompilation 2.33 + * compiler.loopopts.TestBeautifyLoops 2.34 + */ 2.35 + 2.36 +package compiler.loopopts; 2.37 + 2.38 +public class TestBeautifyLoops { 2.39 + private int mI = 0; 2.40 + private long mJ = 0; 2.41 + private float mF = 0f; 2.42 + 2.43 + public void testMethod() { 2.44 + for (int i0 = 0; i0 < 100; i0++) { 2.45 + if (mF != 0) { 2.46 + // do nothing 2.47 + } else { 2.48 + try { 2.49 + mJ = Long.MAX_VALUE; 2.50 + for (int i1 = 0; i1 < 101; i1++) { 2.51 + for (int i2 = 0; i2 < 102; i2++) { 2.52 + mI = new Integer(0x1234); 2.53 + } 2.54 + } 2.55 + } catch (Exception ignored) {} 2.56 + } 2.57 + } 2.58 + } 2.59 + 2.60 + public static void main(String[] args) { 2.61 + TestBeautifyLoops obj = new TestBeautifyLoops(); 2.62 + obj.testMethod(); 2.63 + } 2.64 +}