# HG changeset patch # User Thomas Wuerthinger # Date 1425319786 -3600 # Node ID e17923568367d56e5289a262665c74a8d02160f2 # Parent 84776a6314d741709e6228db63b29bba7bf675a9 Handle case in new earliest schedule when end node and begin node are identical. diff -r 84776a6314d7 -r e17923568367 graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java --- a/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java Mon Mar 02 17:07:51 2015 +0100 +++ b/graal/com.oracle.graal.phases/src/com/oracle/graal/phases/schedule/SchedulePhase.java Mon Mar 02 19:09:46 2015 +0100 @@ -348,8 +348,8 @@ // Add begin nodes as the first entry and set the block for phi nodes. for (Block b : cfg.getBlocks()) { AbstractBeginNode beginNode = b.getBeginNode(); + ArrayList nodes = new ArrayList<>(); nodeToBlock.set(beginNode, b); - ArrayList nodes = new ArrayList<>(); nodes.add(beginNode); blockToNodes.put(b, nodes); @@ -399,12 +399,20 @@ // Add end nodes as the last nodes in each block. for (Block b : cfg.getBlocks()) { - blockToNodes.get(b).add(b.getEndNode()); + FixedNode endNode = b.getEndNode(); + if (endNode != b.getBeginNode()) { + addNode(blockToNodes, b, endNode); + } } this.blockToNodesMap = blockToNodes; } + private static void addNode(BlockMap> blockToNodes, Block b, ValueNode endNode) { + assert !blockToNodes.get(b).contains(endNode) : endNode; + blockToNodes.get(b).add(endNode); + } + private void processStack(BlockMap> blockToNodes, NodeMap nodeToBlock, NodeBitMap visited, Stack stack) { Block startBlock = cfg.getStartBlock(); while (!stack.isEmpty()) { @@ -439,36 +447,35 @@ if (nodeToBlock.get(current) == null) { Node predecessor = current.predecessor(); - if (nodeToBlock.get(current) == null) { - Block curBlock; - if (predecessor != null) { - // Predecessor determines block. - curBlock = nodeToBlock.get(predecessor); - } else { - Block earliest = startBlock; - for (Node input : current.inputs()) { - if (current instanceof FrameState && input instanceof StateSplit && ((StateSplit) input).stateAfter() == current) { - // ignore + Block curBlock; + if (predecessor != null) { + // Predecessor determines block. + curBlock = nodeToBlock.get(predecessor); + } else { + Block earliest = startBlock; + for (Node input : current.inputs()) { + if (current instanceof FrameState && input instanceof StateSplit && ((StateSplit) input).stateAfter() == current) { + // ignore + } else { + Block inputEarliest; + if (input instanceof ControlSplitNode) { + inputEarliest = nodeToBlock.get(((ControlSplitNode) input).getPrimarySuccessor()); } else { - Block inputEarliest; - if (input instanceof ControlSplitNode) { - inputEarliest = nodeToBlock.get(((ControlSplitNode) input).getPrimarySuccessor()); - } else { - inputEarliest = nodeToBlock.get(input); - } - assert inputEarliest != null : current + " / " + input; - if (earliest.getDominatorDepth() < inputEarliest.getDominatorDepth()) { - earliest = inputEarliest; - } + inputEarliest = nodeToBlock.get(input); + } + assert inputEarliest != null : current + " / " + input; + if (earliest.getDominatorDepth() < inputEarliest.getDominatorDepth()) { + earliest = inputEarliest; } } - curBlock = earliest; } - if (current instanceof ValueNode) { - blockToNodes.get(curBlock).add((ValueNode) current); - } - nodeToBlock.set(current, curBlock); + curBlock = earliest; } + assert curBlock != null; + if (current instanceof ValueNode) { + addNode(blockToNodes, curBlock, (ValueNode) current); + } + nodeToBlock.set(current, curBlock); } } }