Skip to content

Commit 8cf5fb8

Browse files
committed
assert no gvn is done after fixing reads
1 parent 7ccdf1f commit 8cf5fb8

File tree

3 files changed

+24
-19
lines changed

3 files changed

+24
-19
lines changed

compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/core/phases/LowTier.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,20 @@ static class Options {
5858
}
5959

6060
private final CanonicalizerPhase canonicalizerWithoutGVN;
61+
private final CanonicalizerPhase canonicalizerWithGVN;
6162

6263
@SuppressWarnings("this-escape")
6364
public LowTier(OptionValues options) {
64-
CanonicalizerPhase canonicalizer = CanonicalizerPhase.create();
65-
this.canonicalizerWithoutGVN = canonicalizer.copyWithoutGVN();
65+
this.canonicalizerWithGVN = CanonicalizerPhase.create();
66+
this.canonicalizerWithoutGVN = canonicalizerWithGVN.copyWithoutGVN();
6667

6768
if (Options.ProfileCompiledMethods.getValue(options)) {
6869
appendPhase(new ProfileCompiledMethodsPhase());
6970
}
7071

71-
appendPhase(new LowTierLoweringPhase(canonicalizer));
72+
appendPhase(new LowTierLoweringPhase(canonicalizerWithGVN));
7273

73-
appendPhase(new ExpandLogicPhase(canonicalizer));
74+
appendPhase(new ExpandLogicPhase(canonicalizerWithGVN));
7475

7576
appendPhase(new FixReadsPhase(true,
7677
new SchedulePhase(GraalOptions.StressTestEarlyReads.getValue(options) ? SchedulingStrategy.EARLIEST : SchedulingStrategy.LATEST_OUT_OF_LOOPS_IMPLICIT_NULL_CHECKS)));
@@ -95,7 +96,11 @@ public LowTier(OptionValues options) {
9596
appendPhase(new SchedulePhase(SchedulePhase.SchedulingStrategy.LATEST_OUT_OF_LOOPS));
9697
}
9798

98-
public CanonicalizerPhase getCanonicalizerWithoutGVN() {
99+
public final CanonicalizerPhase getCanonicalizerWithoutGVN() {
99100
return canonicalizerWithoutGVN;
100101
}
102+
103+
public final CanonicalizerPhase getCanonicalizer() {
104+
return canonicalizerWithGVN;
105+
}
101106
}

compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/phases/common/CanonicalizerPhase.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ public static boolean gvn(Node node, NodeClass<?> nodeClass) {
527527
}
528528

529529
public boolean tryGlobalValueNumbering(Node node, NodeClass<?> nodeClass) {
530+
assert ((StructuredGraph) node.graph()).getGraphState().isBeforeStage(StageFlag.FIXED_READS) : "GVN must not occur after fixing reads, trying to gvn " + node + " for graph " + node.graph();
530531
return gvn(node, nodeClass);
531532
}
532533

compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/virtual/phases/ea/ReadEliminationBlockState.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -204,20 +204,19 @@ public void killReadCache(LocationIdentity identity, ValueNode index, ValueNode
204204
}
205205
}
206206
return;
207-
} else {
208-
Iterator<CacheEntry<?>> iterator = readCache.getKeys().iterator();
209-
while (iterator.hasNext()) {
210-
CacheEntry<?> entry = iterator.next();
211-
/*
212-
* We cover multiple cases here but in general index and array can only be !=null
213-
* for indexed nodes thus the location identity of other accesses (field and object
214-
* locations) will never be the same and will never alias with array accesses.
215-
*
216-
* Unsafe accesses will alias if they are writing to any location.
217-
*/
218-
if (entry.conflicts(identity, index, array)) {
219-
iterator.remove();
220-
}
207+
}
208+
Iterator<CacheEntry<?>> iterator = readCache.getKeys().iterator();
209+
while (iterator.hasNext()) {
210+
CacheEntry<?> entry = iterator.next();
211+
/*
212+
* We cover multiple cases here but in general index and array can only be !=null for
213+
* indexed nodes thus the location identity of other accesses (field and object
214+
* locations) will never be the same and will never alias with array accesses.
215+
*
216+
* Unsafe accesses will alias if they are writing to any location.
217+
*/
218+
if (entry.conflicts(identity, index, array)) {
219+
iterator.remove();
221220
}
222221
}
223222
}

0 commit comments

Comments
 (0)