Skip to content

Commit e3a1904

Browse files
davleopobulasevich
authored andcommitted
pi node: guard against deletion in recursion
(cherry picked from commit 3e3e0f0)
1 parent 31dd718 commit e3a1904

File tree

1 file changed

+17
-1
lines changed
  • compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/nodes

1 file changed

+17
-1
lines changed

compiler/src/jdk.internal.vm.compiler/src/org/graalvm/compiler/nodes/PiNode.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
import static org.graalvm.compiler.nodeinfo.NodeCycles.CYCLES_0;
2828
import static org.graalvm.compiler.nodeinfo.NodeSize.SIZE_0;
2929

30+
import java.util.List;
31+
3032
import org.graalvm.compiler.core.common.type.AbstractPointerStamp;
3133
import org.graalvm.compiler.core.common.type.ObjectStamp;
3234
import org.graalvm.compiler.core.common.type.Stamp;
@@ -307,7 +309,9 @@ private static void tryEvacuate(SimplifierTool tool, GuardingNode guard, boolean
307309
if (guardNode.hasNoUsages()) {
308310
return;
309311
}
310-
for (PiNode pi : guardNode.usages().filter(PiNode.class).snapshot()) {
312+
313+
List<PiNode> pis = guardNode.usages().filter(PiNode.class).snapshot();
314+
for (PiNode pi : pis) {
311315
if (!pi.isAlive()) {
312316
continue;
313317
}
@@ -317,6 +321,8 @@ private static void tryEvacuate(SimplifierTool tool, GuardingNode guard, boolean
317321
}
318322

319323
/*
324+
* RECURSE CALL
325+
*
320326
* If there are PiNodes still anchored at this guard then either they must simplify away
321327
* because they are no longer necessary or this node must be replaced with a
322328
* ValueAnchorNode because the type injected by the PiNode is only true at this point in
@@ -330,6 +336,16 @@ private static void tryEvacuate(SimplifierTool tool, GuardingNode guard, boolean
330336
tryEvacuate(tool, otherGuard, false);
331337
}
332338
}
339+
/*
340+
* A note on the RECURSE CALL above: When we have pis with input pis on the same guard
341+
* (which should actually be combined) it can be that the recurse call (processing the
342+
* same pis again) already deletes this node (very special stamp setups necessary).
343+
* Thus, it can be that pi is dead at this point already, so we have to check for this
344+
* again.
345+
*/
346+
if (!pi.isAlive()) {
347+
continue;
348+
}
333349
Node canonical = pi.canonical(tool);
334350
if (canonical != pi) {
335351
if (!canonical.isAlive()) {

0 commit comments

Comments
 (0)