From 8584a76750ff1dac024123dc7265151311ed250c Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Thu, 13 Dec 2012 19:36:09 +0400 Subject: [PATCH] do not need 'allow dead instructions' after copies are collected (instruction is dead only if all copies are dead) --- .../jet/lang/cfg/pseudocode/PseudocodeImpl.java | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/PseudocodeImpl.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/PseudocodeImpl.java index 72a8b008d50..15815c629a2 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/PseudocodeImpl.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/pseudocode/PseudocodeImpl.java @@ -189,18 +189,23 @@ public class PseudocodeImpl implements Pseudocode { return deadInstructions; } deadInstructions = Lists.newArrayList(); - Collection allowedDeadInstructions = collectAllowedDeadInstructions(); for (Instruction instruction : mutableInstructionList) { - if (((InstructionImpl)instruction).isDead()) { - if (!allowedDeadInstructions.contains(instruction)) { - deadInstructions.add(instruction); - } + if (isDead(instruction)) { + deadInstructions.add(instruction); } } return deadInstructions; } + private static boolean isDead(@NotNull Instruction instruction) { + if (!((InstructionImpl)instruction).isDead()) return false; + for (Instruction copy : instruction.getCopies()) { + if (!((InstructionImpl)copy).isDead()) return false; + } + return true; + } + //for tests only @NotNull public List getLabels() {