-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8307927: C2: "malformed control flow" with irreducible loop #14522
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
test/hotspot/jtreg/compiler/loopopts/MalformedControlIrreducibleLoop.jasm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| /* | ||
| * Copyright (c) 2023, Red Hat, Inc. 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. | ||
| */ | ||
|
|
||
| super public class MalformedControlIrreducibleLoop | ||
| version 52:0 | ||
| { | ||
| public Method "<init>":"()V" | ||
| stack 1 locals 1 | ||
| { | ||
| aload_0; | ||
| invokespecial Method java/lang/Object."<init>":"()V"; | ||
| return; | ||
| } | ||
| /* same as: | ||
| public static void actualTest(int flag) { | ||
| int i = 1; | ||
| int j = 1; | ||
| if (flag == 2) { | ||
| // goto second_entry; | ||
| } | ||
| loop: | ||
| for (;;) { | ||
| i = 1; | ||
| // second_entry: | ||
| do { | ||
| if (i == 1) { | ||
| continue loop; // goto loop | ||
| } | ||
| i *= 2; | ||
| j *= 2; | ||
| } while (j < 2); | ||
| break; | ||
| } | ||
| } | ||
| */ | ||
| public static Method actualTest:"(I)V" | ||
| stack 2 locals 3 | ||
| { | ||
| iconst_1; | ||
| istore_1; | ||
| iconst_1; | ||
| istore_2; | ||
| iload_0; | ||
| iconst_2; | ||
| if_icmpne L11; | ||
| L9: stack_frame_type append; | ||
| locals_map int, int; | ||
| iconst_1; | ||
| istore_1; | ||
| L11: stack_frame_type same; | ||
| iload_1; | ||
| iconst_1; | ||
| if_icmpeq L9; | ||
| L19: stack_frame_type same; | ||
| iload_1; | ||
| iconst_2; | ||
| imul; | ||
| istore_1; | ||
| iload_2; | ||
| iconst_2; | ||
| imul; | ||
| istore_2; | ||
| iload_2; | ||
| iconst_2; | ||
| if_icmplt L11; | ||
| goto L35; | ||
| L35: stack_frame_type same; | ||
| return; | ||
| } | ||
|
|
||
| } // end Class TestMalformedControlIrreducibleLoop |
46 changes: 46 additions & 0 deletions
46
test/hotspot/jtreg/compiler/loopopts/TestMalformedControlIrreducibleLoop.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| /* | ||
| * Copyright (c) 2023, Red Hat, Inc. 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 8307927 | ||
| * @summary C2: "malformed control flow" with irreducible loop | ||
| * @compile MalformedControlIrreducibleLoop.jasm | ||
| * @run main/othervm -Xcomp -XX:-TieredCompilation -XX:CompileOnly=TestMalformedControlIrreducibleLoop::test TestMalformedControlIrreducibleLoop | ||
| */ | ||
|
|
||
| public class TestMalformedControlIrreducibleLoop { | ||
| public static void main(String[] args) { | ||
| new MalformedControlIrreducibleLoop(); | ||
| test(false); | ||
| } | ||
|
|
||
| private static void test(boolean flag) { | ||
| int i; | ||
| for (i = 1; i < 2; i *= 2) { | ||
| } | ||
| if (flag) { | ||
| MalformedControlIrreducibleLoop.actualTest(i); | ||
| } | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@rwestrel you should update the description here. Suggestion:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also the line above is not accurate enough anymore:
_required_safept->push(n); // save the one closest to the tailFor one: could there not be multiple such SafePoints? If so: what does it mean to take "the closest"? And we may have multiple backedges / tails, now that we allow irreducible loops.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than that the fix looks reasonable to me, thanks for the fix @rwestrel !