-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8371716: C2: Phi node fails Value()'s verification when speculative types clash #28331
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
Open
marc-chevalier
wants to merge
7
commits into
openjdk:master
Choose a base branch
from
marc-chevalier:JDK-8371716
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+208
−0
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
818895e
Filter twice
marc-chevalier 7ac02cb
Fix bug number
marc-chevalier e9f3ac9
IgnoreUnrecognizedVMOptions
marc-chevalier 42fedf0
More test
marc-chevalier 006b1e5
Merge branch 'master' into JDK-8371716
marc-chevalier 7a092da
test
marc-chevalier 1c28403
review
marc-chevalier 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
Some comments aren't visible on the classic Files Changed page.
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
153 changes: 153 additions & 0 deletions
153
test/hotspot/jtreg/compiler/igvn/ClashingSpeculativeTypePhiNode.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,153 @@ | ||
| /* | ||
| * Copyright (c) 2025, Red Hat, Inc. | ||
| * Copyright (c) 2025, Oracle and/or its affiliates. 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 8371716 | ||
| * @summary Ranges can be proven to be disjoint but not orderable (thanks to unsigned range) | ||
| * Comparing such values in such range with != should always be true. | ||
| * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions | ||
| * -XX:-TieredCompilation | ||
| * -XX:-UseOnStackReplacement | ||
| * -XX:-BackgroundCompilation | ||
| * -XX:CompileOnly=${test.main.class}::test1 | ||
| * -XX:CompileCommand=quiet | ||
| * -XX:TypeProfileLevel=222 | ||
| * -XX:+AlwaysIncrementalInline | ||
| * -XX:VerifyIterativeGVN=10 | ||
| * -XX:CompileCommand=dontinline,${test.main.class}::notInlined1 | ||
| * ${test.main.class} | ||
| * | ||
| * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions | ||
| * -XX:+UnlockDiagnosticVMOptions | ||
| * -XX:-TieredCompilation | ||
| * -XX:-UseOnStackReplacement | ||
| * -XX:-BackgroundCompilation | ||
| * -XX:CompileOnly=${test.main.class}::test2 | ||
| * -XX:CompileOnly=${test.main.class}::inlined3 | ||
| * -XX:CompileCommand=quiet | ||
| * -XX:TypeProfileLevel=200 | ||
| * -XX:+AlwaysIncrementalInline | ||
| * -XX:VerifyIterativeGVN=10 | ||
| * -XX:CompileCommand=dontinline,${test.main.class}::notInlined1 | ||
| * -XX:+StressIncrementalInlining | ||
| * ${test.main.class} | ||
| * | ||
| * @run main ${test.main.class} | ||
| */ | ||
|
|
||
| package compiler.igvn; | ||
|
|
||
| public class ClashingSpeculativeTypePhiNode { | ||
| public static void main(String[] args) { | ||
| main1(); | ||
| main2(); | ||
| } | ||
|
|
||
| // 1st case | ||
|
|
||
| static void main1() { | ||
| for (int i = 0; i < 20_000; i++) { | ||
| test1(false); // returns null | ||
| inlined1(true, true); // returns C1 | ||
| inlined2(false); // returns C2 | ||
| } | ||
| } | ||
|
|
||
| private static Object test1(boolean flag1) { | ||
| return inlined1(flag1, false); | ||
| // When inlined1 is inlined | ||
| // return Phi(flag1, inlined2(flag2), null) | ||
| // inlined2 is speculatively returning C1, known from the calls `inlined1(true, true)` in main1 | ||
| // Phi node gets speculative type C1 | ||
| // When inline2 is inlined | ||
| // return Phi[C1](flag1, Phi(false, new C1(), notInlined1()), null) | ||
| // => Phi[C1](flag1, notInlined1(), null) | ||
| // notInlined1 is speculatively returning C2, known from `inline2(false)` in main1 | ||
| // return Phi[C1](flag1, notInlined1()[C2], null) | ||
| // Clashing speculative type between Phi's _type (C1) and union of inputs (C2). | ||
| } | ||
|
|
||
| private static Object inlined1(boolean flag1, boolean flag2) { | ||
| if (flag1) { | ||
| return inlined2(flag2); // C1 | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| private static Object inlined2(boolean flag2) { | ||
| if (flag2) { | ||
| return new C1(); | ||
| } | ||
| return notInlined1(); // C2 | ||
| } | ||
|
|
||
| private static Object notInlined1() { | ||
| return new C2(); | ||
| } | ||
|
|
||
| // 2nd case | ||
|
|
||
| static void main2() { | ||
| for (int i = 0; i < 20_000; i++) { | ||
| inlined3(new C1()); | ||
| } | ||
| for (int i = 0; i < 20_000; i++) { | ||
| test2(true, new C2()); | ||
| test2(false, new C2()); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| private static Object test2(boolean flag1, Object o) { | ||
| o = inlined4(o); | ||
| if (flag1) { | ||
| return inlined3(o); | ||
| } | ||
| return null; | ||
| // We profile only parameters. Param o is speculated to be C2. | ||
| // return Phi(flag1, inline3(inline4(o[C2])), null) | ||
| // We inline inline3 | ||
| // return Phi(flag1, inline4(o[C2])[C1], null) | ||
| // As input of inline3, inline4(o) is speculated to be C1. The Phi has C1 as speculative type in _type | ||
| // return Phi[C1](flag1, o[C2], null) | ||
| // Since o is speculated to be C2 as parameter of test2, we get a clash. | ||
| } | ||
|
|
||
| private static Object inlined3(Object o) { | ||
| return o; // C1 | ||
| } | ||
|
|
||
| private static Object inlined4(Object o) { | ||
| return o; | ||
| } | ||
|
|
||
| static class C1 { | ||
|
|
||
| } | ||
|
|
||
| static class C2 { | ||
|
|
||
| } | ||
| } | ||
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.
GitHub Actions is giving us this:
Probably this would help:
-XX:+IgnoreUnrecognizedVMOptions