diff --git a/core/src/main/java/org/teavm/model/lowlevel/ExceptionHandlingShadowStackContributor.java b/core/src/main/java/org/teavm/model/lowlevel/ExceptionHandlingShadowStackContributor.java index 454d12b06..1a096511f 100644 --- a/core/src/main/java/org/teavm/model/lowlevel/ExceptionHandlingShadowStackContributor.java +++ b/core/src/main/java/org/teavm/model/lowlevel/ExceptionHandlingShadowStackContributor.java @@ -395,7 +395,7 @@ public class ExceptionHandlingShadowStackContributor { if (outgoingVariablesToRemove.contains(incoming.getValue().getIndex())) { phi.getIncomings().remove(i--); break; - } else if (incoming.getValue().getIndex() == value) { + } else if (incoming.getValue().getIndex() == value && incoming.getSource() != newBlock) { if (variablesDefinedHere.contains(value)) { incoming.setSource(newBlock); } else { diff --git a/core/src/main/java/org/teavm/model/util/BasicBlockSplitter.java b/core/src/main/java/org/teavm/model/util/BasicBlockSplitter.java index d03cde370..829a39c54 100644 --- a/core/src/main/java/org/teavm/model/util/BasicBlockSplitter.java +++ b/core/src/main/java/org/teavm/model/util/BasicBlockSplitter.java @@ -144,7 +144,7 @@ public class BasicBlockSplitter { DefinitionExtractor defExtractor = new DefinitionExtractor(); for (BasicBlock block : sourceParts) { - if (block != null) { + if (block != source) { for (Map.Entry lastDefinedEntry : lastDefinedValues.entrySet()) { Incoming incomingCopy = new Incoming(); incomingCopy.setSource(block);