From 3ac7bd1c68f480bcf1a670b432549d01b50c04b5 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Sun, 19 Jun 2016 11:52:14 +0300 Subject: [PATCH] Fix bug in LoopInversion --- .../main/java/org/teavm/optimization/LoopInversionImpl.java | 3 +++ core/src/main/java/org/teavm/vm/TeaVM.java | 1 + 2 files changed, 4 insertions(+) diff --git a/core/src/main/java/org/teavm/optimization/LoopInversionImpl.java b/core/src/main/java/org/teavm/optimization/LoopInversionImpl.java index 67e39dbca..2aa2ba880 100644 --- a/core/src/main/java/org/teavm/optimization/LoopInversionImpl.java +++ b/core/src/main/java/org/teavm/optimization/LoopInversionImpl.java @@ -359,6 +359,9 @@ class LoopInversionImpl { for (int node = 0; node < cfg.size(); ++node) { BasicBlock block = program.basicBlockAt(node); + if (copiedNodes.containsKey(block.getIndex())) { + continue; + } for (Phi phi : block.getPhis()) { for (Incoming incoming : phi.getIncomings().toArray(new Incoming[0])) { int source = incoming.getSource().getIndex(); diff --git a/core/src/main/java/org/teavm/vm/TeaVM.java b/core/src/main/java/org/teavm/vm/TeaVM.java index bb2c8aeb5..feeabe4fd 100644 --- a/core/src/main/java/org/teavm/vm/TeaVM.java +++ b/core/src/main/java/org/teavm/vm/TeaVM.java @@ -737,6 +737,7 @@ public class TeaVM implements TeaVMHost, ServiceRepository { private List getOptimizations() { return Arrays.asList( + new RedundantJumpElimination(), new ArrayUnwrapMotion(), new LoopInversion(), new LoopInvariantMotion(),