Program: 132808
Project: 132808
Buggy source:
@Override public List<ValLoc> getResults(){
switch (op) {
case LOAD_SCALAR:
case LOAD_REF:
case LOAD_FILE:
case LOAD_ARRAY:
case LOAD_BAG:
case LOAD_STRUCT:
case LOAD_RECURSIVE:
{
      Arg src=getInput(0);
      Var dst=getOutput(0);
      Closed outIsClosed;
      if (op == Opcode.LOAD_REF) {
        outIsClosed=Closed.MAYBE_NOT;
      }
 else {
        outIsClosed=Closed.YES_NOT_RECURSIVE;
      }
      if (op == Opcode.LOAD_REF) {
        return ValLoc.derefCompVal(dst,src.getVar(),IsValCopy.NO,IsAssign.NO).asList();
      }
 else {
        return vanillaResult(outIsClosed,IsAssign.NO).asList();
      }
    }
case STORE_REF:
case STORE_SCALAR:
case STORE_FILE:
case STORE_ARRAY:
case STORE_BAG:
case STORE_STRUCT:
case STORE_RECURSIVE:
{
    ValLoc assign=vanillaResult(Closed.YES_NOT_RECURSIVE,IsAssign.TO_LOCATION);
    Arg dst=getOutput(0).asArg();
    Arg src=getInput(0);
    if (op == Opcode.STORE_REF) {
      ValLoc retrieve=ValLoc.derefCompVal(src.getVar(),dst.getVar(),IsValCopy.NO,IsAssign.NO);
      return Arrays.asList(retrieve,assign);
    }
 else {
      return assign.asList();
    }
  }
case IS_MAPPED:
{
  ValLoc vanilla=vanillaResult(Closed.YES_NOT_RECURSIVE,IsAssign.TO_LOCATION);
  assert(vanilla != null);
  Var fileVar=getInput(0).getVar();
  if (fileVar.isMapped() == Ternary.MAYBE) {
    return vanilla.asList();
  }
 else {
    Arg result=Arg.createBoolLit(fileVar.isMapped() == Ternary.TRUE);
    return Arrays.asList(vanilla,ValLoc.makeCopy(getOutput(0),result,IsAssign.NO));
  }
}
case GET_FILENAME_ALIAS:
{
Arg filename=getOutput(0).asArg();
Var file=getInput(0).getVar();
return ValLoc.makeFilename(filename,file).asList();
}
case COPY_IN_FILENAME:
{
Arg filename=getInput(0);
Var file=getOutput(0);
return ValLoc.makeFilename(filename,file).asList();
}
case GET_LOCAL_FILENAME:
{
return ValLoc.makeFilenameLocal(getOutput(0).asArg(),getInput(0).getVar(),IsAssign.TO_LOCATION).asList();
}
case SET_FILENAME_VAL:
{
Var file=getOutput(0);
Arg val=getInput(0);
return ValLoc.makeFilenameVal(file,val,IsAssign.TO_VALUE).asList();
}
case GET_FILENAME_VAL:
{
Var file=getInput(0).getVar();
Var val=getOutput(0);
return ValLoc.makeFilenameVal(file,val.asArg(),IsAssign.NO).asList();
}
case DEREF_SCALAR:
case DEREF_FILE:
{
return ValLoc.derefCompVal(getOutput(0),getInput(0).getVar(),IsValCopy.YES,IsAssign.NO).asList();
}
case STRUCT_CREATE_ALIAS:
case STRUCT_COPY_OUT:
case STRUCTREF_COPY_OUT:
{
Var struct=getInput(0).getVar();
List<Arg> fields=getInputsTail(1);
ValLoc copyV=ValLoc.makeStructFieldCopyResult(getOutput(0),struct,fields);
if (op == Opcode.STRUCT_CREATE_ALIAS) {
ValLoc aliasV=ValLoc.makeStructFieldAliasResult(getOutput(0),struct,fields);
return Arrays.asList(aliasV,copyV);
}
 else {
return copyV.asList();
}
}
case STRUCT_RETRIEVE_SUB:
{
Var struct=getInput(0).getVar();
List<Arg> fields=getInputsTail(1);
return ValLoc.makeStructFieldValResult(getOutput(0).asArg(),struct,fields).asList();
}
case STRUCT_INIT_FIELDS:
{
List<ValLoc> results=new ArrayList<ValLoc>();
Out<List<List<Arg>>> fieldPaths=new Out<List<List<Arg>>>();
Out<List<Arg>> fieldVals=new Out<List<Arg>>();
unpackStructInitArgs(null,fieldPaths,fieldVals);
Var struct=getOutput(0);
assert(fieldPaths.val.size() == fieldVals.val.size());
for (int i=0; i < fieldPaths.val.size(); i++) {
ValLoc.makeStructFieldValResult(fieldVals.val.get(i),struct,fieldPaths.val.get(i)).asList();
}
return results;
}
case STRUCT_STORE_SUB:
case STRUCTREF_STORE_SUB:
{
Var struct=getOutput(0);
Arg val=getInput(0);
List<Arg> fields=getInputsTail(1);
return ValLoc.makeStructFieldValResult(val,struct,fields).asList();
}
case STRUCT_COPY_IN:
case STRUCTREF_COPY_IN:
{
Var struct=getOutput(0);
Var val=getInput(0).getVar();
List<Arg> fields=getInputsTail(1);
return ValLoc.makeStructFieldCopyResult(val,struct,fields).asList();
}
case ARR_STORE:
case ARR_STORE_FUTURE:
case AREF_STORE_IMM:
case AREF_STORE_FUTURE:
case ARR_COPY_IN_IMM:
case ARR_COPY_IN_FUTURE:
case AREF_COPY_IN_IMM:
case AREF_COPY_IN_FUTURE:
{
Var arr;
arr=getOutput(0);
Arg ix=getInput(0);
Arg member=getInput(1);
boolean insertingVal=isArrayValStore(op);
return Arrays.asList(ValLoc.makeArrayResult(arr,ix,member,insertingVal,IsAssign.TO_VALUE));
}
case ARRAY_BUILD:
{
Var arr=getOutput(0);
List<ValLoc> res=new ArrayList<ValLoc>();
res.add(ValLoc.buildResult(op,getInputs(),arr.asArg(),Closed.YES_NOT_RECURSIVE,IsAssign.NO));
assert(getInputs().size() % 2 == 0);
int elemCount=getInputs().size() / 2;
for (int i=0; i < elemCount; i++) {
Arg key=getInput(2 * i);
Arg val=getInput(2 * i + 1);
res.add(ValLoc.makeArrayResult(arr,key,val,true,IsAssign.TO_VALUE));
}
res.add(ValLoc.makeContainerSizeCV(arr,Arg.createIntLit(elemCount),false,IsAssign.NO));
return res;
}
case ARR_RETRIEVE:
case ARR_COPY_OUT_IMM:
case ARR_COPY_OUT_FUTURE:
case AREF_COPY_OUT_FUTURE:
case AREF_COPY_OUT_IMM:
{
Var arr=getInput(0).getVar();
Arg ix=getInput(1);
Var contents=getOutput(0);
if (op == Opcode.ARR_RETRIEVE) {
return ValLoc.makeArrayResult(arr,ix,contents.asArg(),true,IsAssign.NO).asList();
}
 else {
assert(Types.isElemType(arr,contents));
return ValLoc.makeArrayResult(arr,ix,contents.asArg(),false,IsAssign.TO_LOCATION).asList();
}
}
case ARR_CREATE_NESTED_FUTURE:
case ARR_CREATE_NESTED_IMM:
case AREF_CREATE_NESTED_FUTURE:
case AREF_CREATE_NESTED_IMM:
case ARRAY_CREATE_BAG:
{
Var nestedArr=getOutput(0);
Var arr=getOutput(1);
Arg ix=getInput(0);
List<ValLoc> res=new ArrayList<ValLoc>();
boolean returnsNonRef=op == Opcode.ARR_CREATE_NESTED_IMM || op == Opcode.ARRAY_CREATE_BAG;
res.add(ValLoc.makeArrayResult(arr,ix,nestedArr.asArg(),returnsNonRef,IsAssign.NO));
res.add(ValLoc.makeCreateNestedResult(arr,ix,nestedArr,returnsNonRef));
return res;
}
case SYNC_COPY_CONTAINER:
case ASYNC_COPY_CONTAINER:
case SYNC_COPY_STRUCT:
case ASYNC_COPY_STRUCT:
{
return ValLoc.makeCopy(getOutput(0),getInput(0),IsAssign.TO_LOCATION).asList();
}
case COPY_REF:
{
Var srcRef=getInput(0).getVar();
return ValLoc.makeAlias(getOutput(0),srcRef).asList();
}
case LOOKUP_CHECKPOINT:
case UNPACK_VALUES:
{
List<ValLoc> res=new ArrayList<ValLoc>(outputs.size());
for (int i=0; i < outputs.size(); i++) {
Var out=outputs.get(i);
res.add(ValLoc.buildResult(op,(Object)i,getInput(0).asList(),out.asArg(),Closed.YES_RECURSIVE,IsValCopy.NO,IsAssign.NO));
}
return res;
}
case PACK_VALUES:
return vanillaResult(Closed.YES_NOT_RECURSIVE,IsAssign.NO).asList();
case CHECKPOINT_LOOKUP_ENABLED:
case CHECKPOINT_WRITE_ENABLED:
return vanillaResult(Closed.YES_NOT_RECURSIVE,IsAssign.NO).asList();
case UNPACK_ARRAY_TO_FLAT:
return vanillaResult(Closed.YES_NOT_RECURSIVE,IsAssign.NO).asList();
case ARR_CONTAINS:
case CONTAINER_SIZE:
case ARR_LOCAL_CONTAINS:
case CONTAINER_LOCAL_SIZE:
return vanillaResult(Closed.YES_NOT_RECURSIVE,IsAssign.NO).asList();
default :
return null;
}
}

Fixed version (ground truth):
@Override public List<ValLoc> getResults(){
switch (op) {
case LOAD_SCALAR:
case LOAD_REF:
case LOAD_FILE:
case LOAD_ARRAY:
case LOAD_BAG:
case LOAD_STRUCT:
case LOAD_RECURSIVE:
{
      Arg src=getInput(0);
      Var dst=getOutput(0);
      Closed outIsClosed;
      if (op == Opcode.LOAD_REF) {
        outIsClosed=Closed.MAYBE_NOT;
      }
 else {
        outIsClosed=Closed.YES_NOT_RECURSIVE;
      }
      if (op == Opcode.LOAD_REF) {
        return ValLoc.derefCompVal(dst,src.getVar(),IsValCopy.NO,IsAssign.NO).asList();
      }
 else {
        return vanillaResult(outIsClosed,IsAssign.NO).asList();
      }
    }
case STORE_REF:
case STORE_SCALAR:
case STORE_FILE:
case STORE_ARRAY:
case STORE_BAG:
case STORE_STRUCT:
case STORE_RECURSIVE:
{
    ValLoc assign=vanillaResult(Closed.YES_NOT_RECURSIVE,IsAssign.TO_LOCATION);
    Arg dst=getOutput(0).asArg();
    Arg src=getInput(0);
    if (op == Opcode.STORE_REF) {
      ValLoc retrieve=ValLoc.derefCompVal(src.getVar(),dst.getVar(),IsValCopy.NO,IsAssign.NO);
      return Arrays.asList(retrieve,assign);
    }
 else {
      return assign.asList();
    }
  }
case IS_MAPPED:
{
  ValLoc vanilla=vanillaResult(Closed.YES_NOT_RECURSIVE,IsAssign.TO_LOCATION);
  assert(vanilla != null);
  Var fileVar=getInput(0).getVar();
  if (fileVar.isMapped() == Ternary.MAYBE) {
    return vanilla.asList();
  }
 else {
    Arg result=Arg.createBoolLit(fileVar.isMapped() == Ternary.TRUE);
    return Arrays.asList(vanilla,ValLoc.makeCopy(getOutput(0),result,IsAssign.NO));
  }
}
case GET_FILENAME_ALIAS:
{
Arg filename=getOutput(0).asArg();
Var file=getInput(0).getVar();
return ValLoc.makeFilename(filename,file).asList();
}
case COPY_IN_FILENAME:
{
Arg filename=getInput(0);
Var file=getOutput(0);
return ValLoc.makeFilename(filename,file).asList();
}
case GET_LOCAL_FILENAME:
{
return ValLoc.makeFilenameLocal(getOutput(0).asArg(),getInput(0).getVar(),IsAssign.TO_LOCATION).asList();
}
case SET_FILENAME_VAL:
{
Var file=getOutput(0);
Arg val=getInput(0);
return ValLoc.makeFilenameVal(file,val,IsAssign.TO_VALUE).asList();
}
case GET_FILENAME_VAL:
{
Var file=getInput(0).getVar();
Var val=getOutput(0);
return ValLoc.makeFilenameVal(file,val.asArg(),IsAssign.NO).asList();
}
case DEREF_SCALAR:
case DEREF_FILE:
{
return ValLoc.derefCompVal(getOutput(0),getInput(0).getVar(),IsValCopy.YES,IsAssign.NO).asList();
}
case STRUCT_CREATE_ALIAS:
case STRUCT_COPY_OUT:
case STRUCTREF_COPY_OUT:
{
Var struct=getInput(0).getVar();
List<Arg> fields=getInputsTail(1);
ValLoc copyV=ValLoc.makeStructFieldCopyResult(getOutput(0),struct,fields);
if (op == Opcode.STRUCT_CREATE_ALIAS) {
ValLoc aliasV=ValLoc.makeStructFieldAliasResult(getOutput(0),struct,fields);
return Arrays.asList(aliasV,copyV);
}
 else {
return copyV.asList();
}
}
case STRUCT_RETRIEVE_SUB:
{
Var struct=getInput(0).getVar();
List<Arg> fields=getInputsTail(1);
return ValLoc.makeStructFieldValResult(getOutput(0).asArg(),struct,fields).asList();
}
case STRUCT_INIT_FIELDS:
{
List<ValLoc> results=new ArrayList<ValLoc>();
Out<List<List<Arg>>> fieldPaths=new Out<List<List<Arg>>>();
Out<List<Arg>> fieldVals=new Out<List<Arg>>();
unpackStructInitArgs(null,fieldPaths,fieldVals);
Var struct=getOutput(0);
assert(fieldPaths.val.size() == fieldVals.val.size());
for (int i=0; i < fieldPaths.val.size(); i++) {
results.add(ValLoc.makeStructFieldValResult(fieldVals.val.get(i),struct,fieldPaths.val.get(i)));
}
return results;
}
case STRUCT_STORE_SUB:
case STRUCTREF_STORE_SUB:
{
Var struct=getOutput(0);
Arg val=getInput(0);
List<Arg> fields=getInputsTail(1);
return ValLoc.makeStructFieldValResult(val,struct,fields).asList();
}
case STRUCT_COPY_IN:
case STRUCTREF_COPY_IN:
{
Var struct=getOutput(0);
Var val=getInput(0).getVar();
List<Arg> fields=getInputsTail(1);
return ValLoc.makeStructFieldCopyResult(val,struct,fields).asList();
}
case ARR_STORE:
case ARR_STORE_FUTURE:
case AREF_STORE_IMM:
case AREF_STORE_FUTURE:
case ARR_COPY_IN_IMM:
case ARR_COPY_IN_FUTURE:
case AREF_COPY_IN_IMM:
case AREF_COPY_IN_FUTURE:
{
Var arr;
arr=getOutput(0);
Arg ix=getInput(0);
Arg member=getInput(1);
boolean insertingVal=isArrayValStore(op);
return Arrays.asList(ValLoc.makeArrayResult(arr,ix,member,insertingVal,IsAssign.TO_VALUE));
}
case ARRAY_BUILD:
{
Var arr=getOutput(0);
List<ValLoc> res=new ArrayList<ValLoc>();
res.add(ValLoc.buildResult(op,getInputs(),arr.asArg(),Closed.YES_NOT_RECURSIVE,IsAssign.NO));
assert(getInputs().size() % 2 == 0);
int elemCount=getInputs().size() / 2;
for (int i=0; i < elemCount; i++) {
Arg key=getInput(2 * i);
Arg val=getInput(2 * i + 1);
res.add(ValLoc.makeArrayResult(arr,key,val,true,IsAssign.TO_VALUE));
}
res.add(ValLoc.makeContainerSizeCV(arr,Arg.createIntLit(elemCount),false,IsAssign.NO));
return res;
}
case ARR_RETRIEVE:
case ARR_COPY_OUT_IMM:
case ARR_COPY_OUT_FUTURE:
case AREF_COPY_OUT_FUTURE:
case AREF_COPY_OUT_IMM:
{
Var arr=getInput(0).getVar();
Arg ix=getInput(1);
Var contents=getOutput(0);
if (op == Opcode.ARR_RETRIEVE) {
return ValLoc.makeArrayResult(arr,ix,contents.asArg(),true,IsAssign.NO).asList();
}
 else {
assert(Types.isElemType(arr,contents));
return ValLoc.makeArrayResult(arr,ix,contents.asArg(),false,IsAssign.TO_LOCATION).asList();
}
}
case ARR_CREATE_NESTED_FUTURE:
case ARR_CREATE_NESTED_IMM:
case AREF_CREATE_NESTED_FUTURE:
case AREF_CREATE_NESTED_IMM:
case ARRAY_CREATE_BAG:
{
Var nestedArr=getOutput(0);
Var arr=getOutput(1);
Arg ix=getInput(0);
List<ValLoc> res=new ArrayList<ValLoc>();
boolean returnsNonRef=op == Opcode.ARR_CREATE_NESTED_IMM || op == Opcode.ARRAY_CREATE_BAG;
res.add(ValLoc.makeArrayResult(arr,ix,nestedArr.asArg(),returnsNonRef,IsAssign.NO));
res.add(ValLoc.makeCreateNestedResult(arr,ix,nestedArr,returnsNonRef));
return res;
}
case SYNC_COPY_CONTAINER:
case ASYNC_COPY_CONTAINER:
case SYNC_COPY_STRUCT:
case ASYNC_COPY_STRUCT:
{
return ValLoc.makeCopy(getOutput(0),getInput(0),IsAssign.TO_LOCATION).asList();
}
case COPY_REF:
{
Var srcRef=getInput(0).getVar();
return ValLoc.makeAlias(getOutput(0),srcRef).asList();
}
case LOOKUP_CHECKPOINT:
case UNPACK_VALUES:
{
List<ValLoc> res=new ArrayList<ValLoc>(outputs.size());
for (int i=0; i < outputs.size(); i++) {
Var out=outputs.get(i);
res.add(ValLoc.buildResult(op,(Object)i,getInput(0).asList(),out.asArg(),Closed.YES_RECURSIVE,IsValCopy.NO,IsAssign.NO));
}
return res;
}
case PACK_VALUES:
return vanillaResult(Closed.YES_NOT_RECURSIVE,IsAssign.NO).asList();
case CHECKPOINT_LOOKUP_ENABLED:
case CHECKPOINT_WRITE_ENABLED:
return vanillaResult(Closed.YES_NOT_RECURSIVE,IsAssign.NO).asList();
case UNPACK_ARRAY_TO_FLAT:
return vanillaResult(Closed.YES_NOT_RECURSIVE,IsAssign.NO).asList();
case ARR_CONTAINS:
case CONTAINER_SIZE:
case ARR_LOCAL_CONTAINS:
case CONTAINER_LOCAL_SIZE:
return vanillaResult(Closed.YES_NOT_RECURSIVE,IsAssign.NO).asList();
default :
return null;
}
}