Program: 149810
Project: 149810
Buggy source:
/** 
 * Perform local constant propagation for a method.
 * @param ir the IR to optimize
 */
public void perform(IR ir){
  HashMap<Register,Operand> info=new HashMap<Register,Operand>();
  for (BasicBlock bb=ir.firstBasicBlockInCodeOrder(); bb != null; bb=bb.nextBasicBlockInCodeOrder()) {
    if (bb.isEmpty())     continue;
    container.counter2++;
    if (bb.getInfrequent()) {
      container.counter1++;
      if (ir.options.FREQ_FOCUS_EFFORT)       continue;
    }
    for (Instruction s=bb.firstRealInstruction(), sentinel=bb.lastInstruction(); s != sentinel; s=s.nextInstructionInCodeOrder()) {
      if (!info.isEmpty()) {
        int numUses=s.getNumberOfUses();
        if (numUses > 0) {
          boolean didSomething=false;
          for (OperandEnumeration e=s.getUses(); e.hasMoreElements(); ) {
            Operand use=e.next();
            if (use instanceof RegisterOperand) {
              RegisterOperand rUse=(RegisterOperand)use;
              Operand value=info.get(rUse.getRegister());
              if (value != null) {
                didSomething=true;
                value=value.copy();
                if (value instanceof RegisterOperand) {
                  ((RegisterOperand)value).copyType(rUse);
                }
                s.replaceOperand(use,value);
              }
            }
          }
          if (didSomething)           Simplifier.simplify(ir.IRStage == IR.HIR,ir.regpool,s);
        }
        boolean killPhysicals=s.isTSPoint() || s.operator().implicitDefs != 0;
        if (killPhysicals) {
          HashSet<Register> toRemove=new HashSet<Register>();
          for (          Map.Entry<Register,Operand> entry : info.entrySet()) {
            Register eR=entry.getValue().asRegister().getRegister();
            if (killPhysicals && eR.isPhysical()) {
              toRemove.add(entry.getKey());
            }
          }
          for (          final Register aToRemove : toRemove) {
            info.remove(aToRemove);
          }
        }
        for (OperandEnumeration e=s.getDefs(); e.hasMoreElements(); ) {
          Operand def=e.next();
          if (def != null && def.isRegister()) {
            Register r=def.asRegister().getRegister();
            info.remove(r);
            HashSet<Register> toRemove=new HashSet<Register>();
            for (            Map.Entry<Register,Operand> entry : info.entrySet()) {
              Register eR=((RegisterOperand)entry.getValue()).getRegister();
              if (eR == r) {
                toRemove.add(entry.getKey());
              }
            }
            for (            final Register register : toRemove) {
              info.remove(register);
            }
          }
        }
      }
      if (Move.conforms(s)) {
        Operand val=Move.getVal(s);
        if (val.isRegister() && !val.asRegister().getRegister().isPhysical()) {
          info.put(Move.getResult(s).getRegister(),val);
        }
      }
    }
    info.clear();
  }
}

Fixed version (ground truth):
/** 
 * Perform local constant propagation for a method.
 * @param ir the IR to optimize
 */
public void perform(IR ir){
  HashMap<Register,Operand> info=new HashMap<Register,Operand>();
  for (BasicBlock bb=ir.firstBasicBlockInCodeOrder(); bb != null; bb=bb.nextBasicBlockInCodeOrder()) {
    if (bb.isEmpty())     continue;
    container.counter2++;
    if (bb.getInfrequent()) {
      container.counter1++;
      if (ir.options.FREQ_FOCUS_EFFORT)       continue;
    }
    for (Instruction s=bb.firstRealInstruction(), sentinel=bb.lastInstruction(); s != sentinel; s=s.nextInstructionInCodeOrder()) {
      if (!info.isEmpty()) {
        int numUses=s.getNumberOfPureUses();
        if (numUses > 0) {
          boolean didSomething=false;
          for (OperandEnumeration e=s.getUses(); e.hasMoreElements(); ) {
            Operand use=e.next();
            if (use instanceof RegisterOperand) {
              RegisterOperand rUse=(RegisterOperand)use;
              Operand value=info.get(rUse.getRegister());
              if (value != null) {
                didSomething=true;
                value=value.copy();
                if (value instanceof RegisterOperand) {
                  ((RegisterOperand)value).copyType(rUse);
                }
                s.replaceOperand(use,value);
              }
            }
          }
          if (didSomething)           Simplifier.simplify(ir.IRStage == IR.HIR,ir.regpool,s);
        }
        boolean killPhysicals=s.isTSPoint() || s.operator().implicitDefs != 0;
        if (killPhysicals) {
          HashSet<Register> toRemove=new HashSet<Register>();
          for (          Map.Entry<Register,Operand> entry : info.entrySet()) {
            Register eR=entry.getValue().asRegister().getRegister();
            if (killPhysicals && eR.isPhysical()) {
              toRemove.add(entry.getKey());
            }
          }
          for (          final Register aToRemove : toRemove) {
            info.remove(aToRemove);
          }
        }
        for (OperandEnumeration e=s.getDefs(); e.hasMoreElements(); ) {
          Operand def=e.next();
          if (def != null && def.isRegister()) {
            Register r=def.asRegister().getRegister();
            info.remove(r);
            HashSet<Register> toRemove=new HashSet<Register>();
            for (            Map.Entry<Register,Operand> entry : info.entrySet()) {
              Register eR=((RegisterOperand)entry.getValue()).getRegister();
              if (eR == r) {
                toRemove.add(entry.getKey());
              }
            }
            for (            final Register register : toRemove) {
              info.remove(register);
            }
          }
        }
      }
      if (Move.conforms(s)) {
        Operand val=Move.getVal(s);
        if (val.isRegister() && !val.asRegister().getRegister().isPhysical()) {
          info.put(Move.getResult(s).getRegister(),val);
        }
      }
    }
    info.clear();
  }
}