Program: 150075
Project: 150075
Buggy source:
/** 
 * Converts the given HIR to LIR.
 * @param ir IR to convert
 */
static void convert(OPT_IR ir,OPT_Options options){
  for (OPT_Instruction s=ir.firstInstructionInCodeOrder(); s != null; s=s.nextInstructionInCodeOrder()) {
switch (s.getOpcode()) {
case GETSTATIC_opcode:
{
        OPT_LocationOperand loc=GetStatic.getClearLocation(s);
        OPT_RegisterOperand result=GetStatic.getClearResult(s);
        OPT_Operand address=ir.regpool.makeJTOCOp(ir,s);
        OPT_Operand offset=GetStatic.getClearOffset(s);
        Load.mutate(s,OPT_IRTools.getLoadOp(loc.getFieldRef()),result,address,offset,loc);
      }
    break;
case PUTSTATIC_opcode:
{
    OPT_LocationOperand loc=PutStatic.getClearLocation(s);
    OPT_Operand value=PutStatic.getClearValue(s);
    OPT_Operand address=ir.regpool.makeJTOCOp(ir,s);
    OPT_Operand offset=PutStatic.getClearOffset(s);
    Store.mutate(s,OPT_IRTools.getStoreOp(loc.getFieldRef()),value,address,offset,loc);
  }
break;
case PUTFIELD_opcode:
{
OPT_LocationOperand loc=PutField.getClearLocation(s);
OPT_Operand value=PutField.getClearValue(s);
OPT_Operand address=PutField.getClearRef(s);
OPT_Operand offset=PutField.getClearOffset(s);
Store.mutate(s,OPT_IRTools.getStoreOp(loc.getFieldRef()),value,address,offset,loc,PutField.getClearGuard(s));
}
break;
case GETFIELD_opcode:
{
OPT_LocationOperand loc=GetField.getClearLocation(s);
OPT_RegisterOperand result=GetField.getClearResult(s);
OPT_Operand address=GetField.getClearRef(s);
OPT_Operand offset=GetField.getClearOffset(s);
Load.mutate(s,OPT_IRTools.getLoadOp(loc.getFieldRef()),result,address,offset,loc,GetField.getClearGuard(s));
}
break;
case INT_ALOAD_opcode:
doArrayLoad(s,ir,INT_LOAD,2);
break;
case LONG_ALOAD_opcode:
doArrayLoad(s,ir,LONG_LOAD,3);
break;
case FLOAT_ALOAD_opcode:
doArrayLoad(s,ir,FLOAT_LOAD,2);
break;
case DOUBLE_ALOAD_opcode:
doArrayLoad(s,ir,DOUBLE_LOAD,3);
break;
case REF_ALOAD_opcode:
doArrayLoad(s,ir,REF_LOAD,LOG_BYTES_IN_ADDRESS);
break;
case BYTE_ALOAD_opcode:
doArrayLoad(s,ir,BYTE_LOAD,0);
break;
case UBYTE_ALOAD_opcode:
doArrayLoad(s,ir,UBYTE_LOAD,0);
break;
case USHORT_ALOAD_opcode:
doArrayLoad(s,ir,USHORT_LOAD,1);
break;
case SHORT_ALOAD_opcode:
doArrayLoad(s,ir,SHORT_LOAD,1);
break;
case INT_ASTORE_opcode:
doArrayStore(s,ir,INT_STORE,2);
break;
case LONG_ASTORE_opcode:
doArrayStore(s,ir,LONG_STORE,3);
break;
case FLOAT_ASTORE_opcode:
doArrayStore(s,ir,FLOAT_STORE,2);
break;
case DOUBLE_ASTORE_opcode:
doArrayStore(s,ir,DOUBLE_STORE,3);
break;
case REF_ASTORE_opcode:
doArrayStore(s,ir,REF_STORE,LOG_BYTES_IN_ADDRESS);
break;
case BYTE_ASTORE_opcode:
doArrayStore(s,ir,BYTE_STORE,0);
break;
case SHORT_ASTORE_opcode:
doArrayStore(s,ir,SHORT_STORE,1);
break;
case CALL_opcode:
s=callHelper(s,ir);
break;
case SYSCALL_opcode:
OPT_CallingConvention.expandSysCall(s,ir);
break;
case TABLESWITCH_opcode:
s=tableswitch(s,ir);
break;
case LOOKUPSWITCH_opcode:
s=lookup(s,ir);
break;
case OBJARRAY_STORE_CHECK_opcode:
s=OPT_DynamicTypeCheckExpansion.arrayStoreCheck(s,ir,true);
break;
case OBJARRAY_STORE_CHECK_NOTNULL_opcode:
s=OPT_DynamicTypeCheckExpansion.arrayStoreCheck(s,ir,false);
break;
case CHECKCAST_opcode:
case CHECKCAST_UNRESOLVED_opcode:
s=OPT_DynamicTypeCheckExpansion.checkcast(s,ir);
break;
case CHECKCAST_NOTNULL_opcode:
s=OPT_DynamicTypeCheckExpansion.checkcastNotNull(s,ir);
break;
case MUST_IMPLEMENT_INTERFACE_opcode:
s=OPT_DynamicTypeCheckExpansion.mustImplementInterface(s,ir);
break;
case IG_CLASS_TEST_opcode:
IfCmp.mutate(s,REF_IFCMP,null,getTIB(s,ir,InlineGuard.getClearValue(s),InlineGuard.getClearGuard(s)),getTIB(s,ir,InlineGuard.getGoal(s).asType()),OPT_ConditionOperand.NOT_EQUAL(),InlineGuard.getClearTarget(s),InlineGuard.getClearBranchProfile(s));
break;
case IG_METHOD_TEST_opcode:
{
OPT_MethodOperand methOp=InlineGuard.getClearGoal(s).asMethod();
OPT_RegisterOperand t1=getTIB(s,ir,InlineGuard.getClearValue(s),InlineGuard.getClearGuard(s));
OPT_Operand t2=getTIB(s,ir,methOp.getTarget().getDeclaringClass());
IfCmp.mutate(s,REF_IFCMP,null,getInstanceMethod(s,ir,t1,methOp.getTarget()),getInstanceMethod(s,ir,t2,methOp.getTarget()),OPT_ConditionOperand.NOT_EQUAL(),InlineGuard.getClearTarget(s),InlineGuard.getClearBranchProfile(s));
break;
}
case INSTANCEOF_opcode:
case INSTANCEOF_UNRESOLVED_opcode:
s=OPT_DynamicTypeCheckExpansion.instanceOf(s,ir);
break;
case INSTANCEOF_NOTNULL_opcode:
s=OPT_DynamicTypeCheckExpansion.instanceOfNotNull(s,ir);
break;
case INT_ZERO_CHECK_opcode:
{
TrapIf.mutate(s,TRAP_IF,ZeroCheck.getClearGuardResult(s),ZeroCheck.getClearValue(s),IC(0),OPT_ConditionOperand.EQUAL(),OPT_TrapCodeOperand.DivByZero());
}
break;
case LONG_ZERO_CHECK_opcode:
{
TrapIf.mutate(s,TRAP_IF,ZeroCheck.getClearGuardResult(s),ZeroCheck.getClearValue(s),IC(0),OPT_ConditionOperand.EQUAL(),OPT_TrapCodeOperand.DivByZero());
}
break;
case BOUNDS_CHECK_opcode:
{
OPT_RegisterOperand array_length=InsertGuardedUnary(s,ir,ARRAYLENGTH,VM_TypeReference.Int,BoundsCheck.getClearRef(s),BoundsCheck.getClearGuard(s));
TrapIf.mutate(s,TRAP_IF,BoundsCheck.getClearGuardResult(s),array_length.copyD2U(),BoundsCheck.getClearIndex(s),OPT_ConditionOperand.LOWER_EQUAL(),OPT_TrapCodeOperand.ArrayBounds());
}
break;
case GET_CLASS_OBJECT_opcode:
{
OPT_Operand TIB=getTIB(s,ir,(OPT_TypeOperand)Unary.getClearVal(s));
OPT_RegisterOperand type=ir.regpool.makeTemp(VM_TypeReference.VM_Type);
s.insertBefore(Unary.create(GET_TYPE_FROM_TIB,type,TIB));
Load.mutate(s,REF_LOAD,Unary.getClearResult(s),type.copyD2U(),AC(VM_Entrypoints.classForTypeField.getOffset()),null);
}
break;
case RESOLVE_MEMBER_opcode:
s=resolveMember(s,ir);
break;
default :
break;
}
}
}

Fixed version (ground truth):
/** 
 * Converts the given HIR to LIR.
 * @param ir IR to convert
 */
static void convert(OPT_IR ir,OPT_Options options){
  boolean didArrayStoreCheck=false;
  for (OPT_Instruction s=ir.firstInstructionInCodeOrder(); s != null; s=s.nextInstructionInCodeOrder()) {
switch (s.getOpcode()) {
case GETSTATIC_opcode:
{
        OPT_LocationOperand loc=GetStatic.getClearLocation(s);
        OPT_RegisterOperand result=GetStatic.getClearResult(s);
        OPT_Operand address=ir.regpool.makeJTOCOp(ir,s);
        OPT_Operand offset=GetStatic.getClearOffset(s);
        Load.mutate(s,OPT_IRTools.getLoadOp(loc.getFieldRef()),result,address,offset,loc);
      }
    break;
case PUTSTATIC_opcode:
{
    OPT_LocationOperand loc=PutStatic.getClearLocation(s);
    OPT_Operand value=PutStatic.getClearValue(s);
    OPT_Operand address=ir.regpool.makeJTOCOp(ir,s);
    OPT_Operand offset=PutStatic.getClearOffset(s);
    Store.mutate(s,OPT_IRTools.getStoreOp(loc.getFieldRef()),value,address,offset,loc);
  }
break;
case PUTFIELD_opcode:
{
OPT_LocationOperand loc=PutField.getClearLocation(s);
OPT_Operand value=PutField.getClearValue(s);
OPT_Operand address=PutField.getClearRef(s);
OPT_Operand offset=PutField.getClearOffset(s);
Store.mutate(s,OPT_IRTools.getStoreOp(loc.getFieldRef()),value,address,offset,loc,PutField.getClearGuard(s));
}
break;
case GETFIELD_opcode:
{
OPT_LocationOperand loc=GetField.getClearLocation(s);
OPT_RegisterOperand result=GetField.getClearResult(s);
OPT_Operand address=GetField.getClearRef(s);
OPT_Operand offset=GetField.getClearOffset(s);
Load.mutate(s,OPT_IRTools.getLoadOp(loc.getFieldRef()),result,address,offset,loc,GetField.getClearGuard(s));
}
break;
case INT_ALOAD_opcode:
doArrayLoad(s,ir,INT_LOAD,2);
break;
case LONG_ALOAD_opcode:
doArrayLoad(s,ir,LONG_LOAD,3);
break;
case FLOAT_ALOAD_opcode:
doArrayLoad(s,ir,FLOAT_LOAD,2);
break;
case DOUBLE_ALOAD_opcode:
doArrayLoad(s,ir,DOUBLE_LOAD,3);
break;
case REF_ALOAD_opcode:
doArrayLoad(s,ir,REF_LOAD,LOG_BYTES_IN_ADDRESS);
break;
case BYTE_ALOAD_opcode:
doArrayLoad(s,ir,BYTE_LOAD,0);
break;
case UBYTE_ALOAD_opcode:
doArrayLoad(s,ir,UBYTE_LOAD,0);
break;
case USHORT_ALOAD_opcode:
doArrayLoad(s,ir,USHORT_LOAD,1);
break;
case SHORT_ALOAD_opcode:
doArrayLoad(s,ir,SHORT_LOAD,1);
break;
case INT_ASTORE_opcode:
doArrayStore(s,ir,INT_STORE,2);
break;
case LONG_ASTORE_opcode:
doArrayStore(s,ir,LONG_STORE,3);
break;
case FLOAT_ASTORE_opcode:
doArrayStore(s,ir,FLOAT_STORE,2);
break;
case DOUBLE_ASTORE_opcode:
doArrayStore(s,ir,DOUBLE_STORE,3);
break;
case REF_ASTORE_opcode:
doArrayStore(s,ir,REF_STORE,LOG_BYTES_IN_ADDRESS);
break;
case BYTE_ASTORE_opcode:
doArrayStore(s,ir,BYTE_STORE,0);
break;
case SHORT_ASTORE_opcode:
doArrayStore(s,ir,SHORT_STORE,1);
break;
case CALL_opcode:
s=callHelper(s,ir);
break;
case SYSCALL_opcode:
OPT_CallingConvention.expandSysCall(s,ir);
break;
case TABLESWITCH_opcode:
s=tableswitch(s,ir);
break;
case LOOKUPSWITCH_opcode:
s=lookup(s,ir);
break;
case OBJARRAY_STORE_CHECK_opcode:
s=OPT_DynamicTypeCheckExpansion.arrayStoreCheck(s,ir,true);
didArrayStoreCheck=true;
break;
case OBJARRAY_STORE_CHECK_NOTNULL_opcode:
s=OPT_DynamicTypeCheckExpansion.arrayStoreCheck(s,ir,false);
didArrayStoreCheck=true;
break;
case CHECKCAST_opcode:
case CHECKCAST_UNRESOLVED_opcode:
s=OPT_DynamicTypeCheckExpansion.checkcast(s,ir);
break;
case CHECKCAST_NOTNULL_opcode:
s=OPT_DynamicTypeCheckExpansion.checkcastNotNull(s,ir);
break;
case MUST_IMPLEMENT_INTERFACE_opcode:
s=OPT_DynamicTypeCheckExpansion.mustImplementInterface(s,ir);
break;
case IG_CLASS_TEST_opcode:
IfCmp.mutate(s,REF_IFCMP,null,getTIB(s,ir,InlineGuard.getClearValue(s),InlineGuard.getClearGuard(s)),getTIB(s,ir,InlineGuard.getGoal(s).asType()),OPT_ConditionOperand.NOT_EQUAL(),InlineGuard.getClearTarget(s),InlineGuard.getClearBranchProfile(s));
break;
case IG_METHOD_TEST_opcode:
{
OPT_MethodOperand methOp=InlineGuard.getClearGoal(s).asMethod();
OPT_RegisterOperand t1=getTIB(s,ir,InlineGuard.getClearValue(s),InlineGuard.getClearGuard(s));
OPT_Operand t2=getTIB(s,ir,methOp.getTarget().getDeclaringClass());
IfCmp.mutate(s,REF_IFCMP,null,getInstanceMethod(s,ir,t1,methOp.getTarget()),getInstanceMethod(s,ir,t2,methOp.getTarget()),OPT_ConditionOperand.NOT_EQUAL(),InlineGuard.getClearTarget(s),InlineGuard.getClearBranchProfile(s));
break;
}
case INSTANCEOF_opcode:
case INSTANCEOF_UNRESOLVED_opcode:
s=OPT_DynamicTypeCheckExpansion.instanceOf(s,ir);
break;
case INSTANCEOF_NOTNULL_opcode:
s=OPT_DynamicTypeCheckExpansion.instanceOfNotNull(s,ir);
break;
case INT_ZERO_CHECK_opcode:
{
TrapIf.mutate(s,TRAP_IF,ZeroCheck.getClearGuardResult(s),ZeroCheck.getClearValue(s),IC(0),OPT_ConditionOperand.EQUAL(),OPT_TrapCodeOperand.DivByZero());
}
break;
case LONG_ZERO_CHECK_opcode:
{
TrapIf.mutate(s,TRAP_IF,ZeroCheck.getClearGuardResult(s),ZeroCheck.getClearValue(s),IC(0),OPT_ConditionOperand.EQUAL(),OPT_TrapCodeOperand.DivByZero());
}
break;
case BOUNDS_CHECK_opcode:
{
OPT_RegisterOperand array_length=InsertGuardedUnary(s,ir,ARRAYLENGTH,VM_TypeReference.Int,BoundsCheck.getClearRef(s),BoundsCheck.getClearGuard(s));
TrapIf.mutate(s,TRAP_IF,BoundsCheck.getClearGuardResult(s),array_length.copyD2U(),BoundsCheck.getClearIndex(s),OPT_ConditionOperand.LOWER_EQUAL(),OPT_TrapCodeOperand.ArrayBounds());
}
break;
case GET_CLASS_OBJECT_opcode:
{
OPT_Operand TIB=getTIB(s,ir,(OPT_TypeOperand)Unary.getClearVal(s));
OPT_RegisterOperand type=ir.regpool.makeTemp(VM_TypeReference.VM_Type);
s.insertBefore(Unary.create(GET_TYPE_FROM_TIB,type,TIB));
Load.mutate(s,REF_LOAD,Unary.getClearResult(s),type.copyD2U(),AC(VM_Entrypoints.classForTypeField.getOffset()),null);
}
break;
case RESOLVE_MEMBER_opcode:
s=resolveMember(s,ir);
break;
default :
break;
}
}
if (didArrayStoreCheck) {
branchOpts.perform(ir,true);
}
}