# HG changeset patch # User Thomas Wuerthinger # Date 1426011573 -3600 # Node ID 223e1d7b15b75b3a619841ac3741e30db64843ee # Parent 37969636e6f8a8e206215e57151f5f2b7f31a653 Make conditional elimination more robust wrt deleted begin nodes. diff -r 37969636e6f8 -r 223e1d7b15b7 graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DominatorConditionalEliminationPhase.java --- a/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DominatorConditionalEliminationPhase.java Tue Mar 10 15:52:16 2015 +0100 +++ b/graal/com.oracle.graal.phases.common/src/com/oracle/graal/phases/common/DominatorConditionalEliminationPhase.java Tue Mar 10 19:19:33 2015 +0100 @@ -108,7 +108,17 @@ } else { ControlFlowGraph cfg = ControlFlowGraph.compute(graph, true, false, true, true); cfg.computePostdominators(); - blockToNodes = b -> b.getNodes(); + BlockMap> nodes = new BlockMap<>(cfg); + for (Block b : cfg.getBlocks()) { + ArrayList curNodes = new ArrayList<>(); + for (FixedNode node : b.getNodes()) { + if (node instanceof AbstractBeginNode || node instanceof FixedGuardNode || node instanceof CheckCastNode || node instanceof ConditionAnchorNode || node instanceof IfNode) { + curNodes.add(node); + } + } + nodes.put(b, curNodes); + } + blockToNodes = b -> nodes.get(b); nodeToBlock = n -> cfg.blockFor(n); startBlock = cfg.getStartBlock(); } @@ -186,7 +196,7 @@ } else if (node instanceof ConditionAnchorNode) { processConditionAnchor((ConditionAnchorNode) node); } else if (node instanceof IfNode) { - processIf((IfNode) node); + processIf((IfNode) node, undoOperations); } else { return; } @@ -207,7 +217,7 @@ }); } - private void processIf(IfNode node) { + private void processIf(IfNode node, List undoOperations) { tryProofCondition(node.condition(), (guard, result) -> { AbstractBeginNode survivingSuccessor = node.getSuccessor(result); survivingSuccessor.replaceAtUsages(InputType.Guard, guard); @@ -215,7 +225,7 @@ node.replaceAtPredecessor(survivingSuccessor); GraphUtil.killCFG(node); if (survivingSuccessor instanceof BeginNode) { - ((BeginNode) survivingSuccessor).trySimplify(); + undoOperations.add(() -> ((BeginNode) survivingSuccessor).trySimplify()); } }); } @@ -386,8 +396,9 @@ } else { DeoptimizeNode deopt = node.graph().add(new DeoptimizeNode(node.action(), node.reason())); Block block = nodeToBlock.apply(node); - FixedNode next = block.getBeginNode().next(); - block.getBeginNode().setNext(deopt); + AbstractBeginNode beginNode = block.getBeginNode(); + FixedNode next = beginNode.next(); + beginNode.setNext(deopt); GraphUtil.killCFG(next); } })) {