void (ControlFlowGraph graph) { while (true) { boolean merged = false; int originBlocksCount = graph.getBlocks().size(); for (BasicBlock block : graph.getBlocks()) { InstructionSequence seq = block.getSeq(); if (block.getSuccessors().size() == 1) { BasicBlock next = block.getSuccessors().get(0); if (next != graph.getLast() && (seq.isEmpty() || seq.getLastInstr().group != CodeConstants.GROUP_SWITCH)) { if (next.getPredecessors().size() == 1 && next.getPredecessorExceptions().isEmpty() && next != graph.getFirst()) { // TODO: implement a dummy start block boolean sameRanges = true; for (ExceptionRangeCFG range : graph.getExceptions()) { if (range.getProtectedRange().contains(block) ^ range.getProtectedRange().contains(next)) { sameRanges = false; break; } } if (sameRanges) { seq.addSequence(next.getSeq()); block.getOriginalOffsets().addAll(next.getOriginalOffsets()); next.getSeq().clear(); removeEmptyBlock(graph, next, true); merged = true; break; } } } } } if (!merged || graph.getBlocks().size() == originBlocksCount) { break; } } }