Program: 150122
Project: 150122
Buggy source:
/** 
 * This routine is the guts of the SSA construction phase for scalars.  See renameSymbolicRegisters for more details.
 * @param X basic block to search dominator tree from
 * @param S stack of names for each register
 * @param ir governing IR
 */
private void search(OPT_BasicBlock X,Stack[] S){
  if (DEBUG)   System.out.println("String_Node_Str" + X);
  OPT_SSADictionary dictionary=ir.HIRInfo.SSADictionary;
  for (OPT_InstructionEnumeration ie=X.forwardInstrEnumerator(); ie.hasMoreElements(); ) {
    OPT_Instruction A=ie.next();
    if (A.operator() != PHI) {
      for (int u=A.getNumberOfDefs(); u < A.getNumberOfOperands(); u++) {
        OPT_Operand op=A.getOperand(u);
        if (op instanceof OPT_RegisterOperand) {
          OPT_RegisterOperand rop=(OPT_RegisterOperand)op;
          OPT_Register r1=rop.register;
          if (r1.isSSA())           continue;
          if (r1.isPhysical())           continue;
          OPT_RegisterOperand r2=(OPT_RegisterOperand)S[r1.getNumber()].peek();
          if (DEBUG)           System.out.println("String_Node_Str" + r1 + "String_Node_Str"+ r2);
          if (r2 != null) {
            rop.register=r2.register;
            OPT_DefUse.recordUse(rop);
          }
        }
      }
    }
    for (int d=0; d < A.getNumberOfDefs(); d++) {
      OPT_Operand op=A.getOperand(d);
      if (op instanceof OPT_RegisterOperand) {
        OPT_RegisterOperand rop=(OPT_RegisterOperand)op;
        OPT_Register r1=rop.register;
        if (r1.isSSA())         continue;
        if (r1.isPhysical())         continue;
        OPT_Register r2=ir.regpool.getReg(r1);
        if (DEBUG)         System.out.println("String_Node_Str" + r2 + "String_Node_Str"+ r1+ "String_Node_Str"+ A);
        S[r1.getNumber()].push(new OPT_RegisterOperand(r2,rop.type));
        rop.setRegister(r2);
        r2.scratchObject=r1;
      }
    }
  }
  if (DEBUG)   System.out.println("String_Node_Str" + X);
  for (OPT_BasicBlockEnumeration y=X.getOut(); y.hasMoreElements(); ) {
    OPT_BasicBlock Y=y.next();
    if (DEBUG)     System.out.println("String_Node_Str" + Y);
    int j=numPredProcessed[Y.getNumber()]++;
    if (Y.isExit())     continue;
    OPT_Instruction s=Y.firstRealInstruction();
    if (s == null)     continue;
    if (DEBUG)     System.out.println("String_Node_Str" + j);
    while (s.operator() == PHI) {
      OPT_Operand val=Phi.getValue(s,j);
      if (val.isRegister()) {
        OPT_Register r1=((OPT_RegisterOperand)Phi.getValue(s,j)).register;
        if (!r1.isSSA()) {
          OPT_RegisterOperand r2=(OPT_RegisterOperand)S[r1.getNumber()].peek();
          if (r2 == null) {
            Phi.setValue(s,j,new OPT_UnreachableOperand());
          }
 else {
            OPT_RegisterOperand rop=r2.copyRO();
            Phi.setValue(s,j,rop);
            OPT_DefUse.recordUse(rop);
          }
          Phi.setPred(s,j,new OPT_BasicBlockOperand(X));
        }
      }
      s=s.nextInstructionInCodeOrder();
    }
  }
  if (DEBUG)   System.out.println("String_Node_Str" + X);
  for (Enumeration c=ir.HIRInfo.dominatorTree.getChildren(X); c.hasMoreElements(); ) {
    OPT_DominatorTreeNode v=(OPT_DominatorTreeNode)c.nextElement();
    search(v.getBlock(),S);
  }
  if (DEBUG)   System.out.println("String_Node_Str" + X);
  for (OPT_InstructionEnumeration a=X.forwardInstrEnumerator(); a.hasMoreElements(); ) {
    OPT_Instruction A=a.next();
    for (int d=0; d < A.getNumberOfDefs(); d++) {
      OPT_Operand newOp=A.getOperand(d);
      if (newOp == null)       continue;
      if (!newOp.isRegister())       continue;
      OPT_Register newReg=newOp.asRegister().register;
      if (newReg.isSSA())       continue;
      if (newReg.isPhysical())       continue;
      OPT_Register r1=(OPT_Register)newReg.scratchObject;
      S[r1.getNumber()].pop();
      if (DEBUG)       System.out.println("String_Node_Str" + r1);
    }
  }
  if (DEBUG)   System.out.println("String_Node_Str" + X);
}

Fixed version (ground truth):
/** 
 * This routine is the guts of the SSA construction phase for scalars.  See renameSymbolicRegisters for more details.
 * @param X basic block to search dominator tree from
 * @param S stack of names for each register
 */
private void search(OPT_BasicBlock X,Stack[] S){
  if (DEBUG)   System.out.println("String_Node_Str" + X);
  OPT_SSADictionary dictionary=ir.HIRInfo.SSADictionary;
  for (OPT_InstructionEnumeration ie=X.forwardInstrEnumerator(); ie.hasMoreElements(); ) {
    OPT_Instruction A=ie.next();
    if (A.operator() != PHI) {
      for (int u=A.getNumberOfDefs(); u < A.getNumberOfOperands(); u++) {
        OPT_Operand op=A.getOperand(u);
        if (op instanceof OPT_RegisterOperand) {
          OPT_RegisterOperand rop=(OPT_RegisterOperand)op;
          OPT_Register r1=rop.register;
          if (r1.isSSA())           continue;
          if (r1.isPhysical())           continue;
          OPT_RegisterOperand r2=(OPT_RegisterOperand)S[r1.getNumber()].peek();
          if (DEBUG)           System.out.println("String_Node_Str" + r1 + "String_Node_Str"+ r2);
          if (r2 != null) {
            rop.register=r2.register;
            OPT_DefUse.recordUse(rop);
          }
        }
      }
    }
    for (int d=0; d < A.getNumberOfDefs(); d++) {
      OPT_Operand op=A.getOperand(d);
      if (op instanceof OPT_RegisterOperand) {
        OPT_RegisterOperand rop=(OPT_RegisterOperand)op;
        OPT_Register r1=rop.register;
        if (r1.isSSA())         continue;
        if (r1.isPhysical())         continue;
        OPT_Register r2=ir.regpool.getReg(r1);
        if (DEBUG)         System.out.println("String_Node_Str" + r2 + "String_Node_Str"+ r1+ "String_Node_Str"+ A);
        S[r1.getNumber()].push(new OPT_RegisterOperand(r2,rop.type));
        rop.setRegister(r2);
        r2.scratchObject=r1;
      }
    }
  }
  if (DEBUG)   System.out.println("String_Node_Str" + X);
  for (OPT_BasicBlockEnumeration y=X.getOut(); y.hasMoreElements(); ) {
    OPT_BasicBlock Y=y.next();
    if (DEBUG)     System.out.println("String_Node_Str" + Y);
    int j=numPredProcessed[Y.getNumber()]++;
    if (Y.isExit())     continue;
    OPT_Instruction s=Y.firstRealInstruction();
    if (s == null)     continue;
    if (DEBUG)     System.out.println("String_Node_Str" + j);
    while (s.operator() == PHI) {
      OPT_Operand val=Phi.getValue(s,j);
      if (val.isRegister()) {
        OPT_Register r1=((OPT_RegisterOperand)Phi.getValue(s,j)).register;
        if (!r1.isSSA()) {
          OPT_RegisterOperand r2=(OPT_RegisterOperand)S[r1.getNumber()].peek();
          if (r2 == null) {
            Phi.setValue(s,j,new OPT_UnreachableOperand());
          }
 else {
            OPT_RegisterOperand rop=r2.copyRO();
            Phi.setValue(s,j,rop);
            OPT_DefUse.recordUse(rop);
          }
          Phi.setPred(s,j,new OPT_BasicBlockOperand(X));
        }
      }
      s=s.nextInstructionInCodeOrder();
    }
  }
  if (DEBUG)   System.out.println("String_Node_Str" + X);
  for (Enumeration c=ir.HIRInfo.dominatorTree.getChildren(X); c.hasMoreElements(); ) {
    OPT_DominatorTreeNode v=(OPT_DominatorTreeNode)c.nextElement();
    search(v.getBlock(),S);
  }
  if (DEBUG)   System.out.println("String_Node_Str" + X);
  for (OPT_InstructionEnumeration a=X.forwardInstrEnumerator(); a.hasMoreElements(); ) {
    OPT_Instruction A=a.next();
    for (int d=0; d < A.getNumberOfDefs(); d++) {
      OPT_Operand newOp=A.getOperand(d);
      if (newOp == null)       continue;
      if (!newOp.isRegister())       continue;
      OPT_Register newReg=newOp.asRegister().register;
      if (newReg.isSSA())       continue;
      if (newReg.isPhysical())       continue;
      OPT_Register r1=(OPT_Register)newReg.scratchObject;
      S[r1.getNumber()].pop();
      if (DEBUG)       System.out.println("String_Node_Str" + r1);
    }
  }
  if (DEBUG)   System.out.println("String_Node_Str" + X);
}