// Split critical edges in the graph. A critical edge is an edge which // is neither its successor's only predecessor, nor its predecessor's // only successor. Critical edges must be split to prevent copy-insertion // and code motion from affecting other edges. It is probably not strictly // needed here. public static void SplitCriticalEdges(LBlock[] blocks) { for (var i = 0; i < blocks.Length; i++) { var block = blocks[i]; if (block.numSuccessors < 2) { continue; } for (var j = 0; j < block.numSuccessors; j++) { var target = block.getSuccessor(j); if (target.numPredecessors < 2) { continue; } // Create a new block inheriting from the predecessor. var split = new LBlock(block.pc); var ins = new LGoto(target); LInstruction[] instructions = { ins }; split.setInstructions(instructions); block.replaceSuccessor(j, split); target.replacePredecessor(block, split); split.addPredecessor(block); } } }
private void transitionBlocks(LBlock next) { //Debug.Assert(pending_.Count == 0 || block_ != null); if (block_ != null) { //Debug.Assert(pending_[pending_.Count - 1].isControl()); //Debug.Assert(block_.pc >= lir_.entry_pc && block_.pc < lir_.exit_pc); block_.setInstructions(pending_.ToArray()); pending_.Clear(); } block_ = next; }
// Split critical edges in the graph. A critical edge is an edge which // is neither its successor's only predecessor, nor its predecessor's // only successor. Critical edges must be split to prevent copy-insertion // and code motion from affecting other edges. It is probably not strictly // needed here. public static void SplitCriticalEdges(LBlock[] blocks) { for (int i = 0; i < blocks.Length; i++) { LBlock block = blocks[i]; if (block.numSuccessors < 2) continue; for (int j = 0; j < block.numSuccessors; j++) { LBlock target = block.getSuccessor(j); if (target.numPredecessors < 2) continue; // Create a new block inheriting from the predecessor. LBlock split = new LBlock(block.pc); LGoto ins = new LGoto(target); LInstruction[] instructions = { ins }; split.setInstructions(instructions); block.replaceSuccessor(j, split); target.replacePredecessor(block, split); split.addPredecessor(block); } } }