Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8293978: Duplicate simple loop back-edge will crash the vm
Reviewed-by: roland, chagedorn
  • Loading branch information
casparcwang authored and DamonFool committed Sep 21, 2022
1 parent cddd6de commit cb72f80
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/hotspot/share/opto/loopopts.cpp
Expand Up @@ -3920,7 +3920,8 @@ bool PhaseIdealLoop::duplicate_loop_backedge(IdealLoopTree *loop, Node_List &old
}

// With an extra phi for the candidate iv?
if (!incr->is_Phi()) {
// Or the region node is the loop head
if (!incr->is_Phi() || incr->in(0) == head) {
return false;
}

Expand Down
@@ -0,0 +1,65 @@
/*
* Copyright (c) 2022 THL A29 Limited, a Tencent company. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

/**
* @test
* @bug 8293978
* @summary Crash in PhaseIdealLoop::verify_strip_mined_scheduling
*
* @run main/othervm -Xbatch TestDuplicateSimpleLoopBackedge
*
*/

public class TestDuplicateSimpleLoopBackedge {
static void zero(Byte[] a) {
for (int e = 0; e < a.length; e++) {
a[e] = 0;
}
}

int foo(int g) {
Byte h[] = new Byte[500];
zero(h);
short i = 7;
while (i != 1) {
i = (short)(i - 3);
}
return 0;
}

void bar(String[] k) {
try {
int l = 5;
if (l < foo(l)) {
}
} catch (Exception m) {
}
}

public static void main(String[] args) {
TestDuplicateSimpleLoopBackedge n = new TestDuplicateSimpleLoopBackedge();
for (int i = 0; i < 10000; ++i) {
n.bar(args);
}
}
}

1 comment on commit cb72f80

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.