diff --git a/core/src/main/java/org/teavm/ast/optimization/Optimizer.java b/core/src/main/java/org/teavm/ast/optimization/Optimizer.java index 98ff2ff09..466898afc 100644 --- a/core/src/main/java/org/teavm/ast/optimization/Optimizer.java +++ b/core/src/main/java/org/teavm/ast/optimization/Optimizer.java @@ -125,7 +125,7 @@ public class Optimizer { DefinitionExtractor defExtractor = new DefinitionExtractor(); UsageExtractor useExtractor = new UsageExtractor(); BasicBlock block = originalProgram.basicBlockAt(originalBlocks[i]); - Instruction splitPoint = splitPoints[i]; + Instruction splitPoint = splitPoints[i].getPrevious(); for (Instruction insn = block.getLastInstruction(); insn != splitPoint; insn = insn.getPrevious()) { insn.acceptVisitor(defExtractor); insn.acceptVisitor(useExtractor); diff --git a/core/src/main/java/org/teavm/model/util/ProgramNodeSplittingBackend.java b/core/src/main/java/org/teavm/model/util/ProgramNodeSplittingBackend.java index 9250598cd..61ea875d6 100644 --- a/core/src/main/java/org/teavm/model/util/ProgramNodeSplittingBackend.java +++ b/core/src/main/java/org/teavm/model/util/ProgramNodeSplittingBackend.java @@ -36,9 +36,7 @@ public class ProgramNodeSplittingBackend implements GraphSplittingBackend { int node = nodes[i]; BasicBlock block = program.basicBlockAt(node); BasicBlock blockCopy = program.createBasicBlock(); - blockCopy.addAll(ProgramUtils.copyInstructions(block.getFirstInstruction(), null, program)); - blockCopy.getTryCatchBlocks().addAll(ProgramUtils.copyTryCatches(block, program)); - blockCopy.setExceptionVariable(block.getExceptionVariable()); + ProgramUtils.copyBasicBlock(block, blockCopy); copies[i] = blockCopy.getIndex(); map.put(nodes[i], copies[i] + 1); }