Program: 150060
Project: 150060
Buggy source:
/** 
 * Stage 1: Complete the expression trees and identify tree roots. Complete BURS trees by adding leaf nodes as needed, and creating tree edges by calling insertChild1() or insertChild2() This step is also where we introduce intermediate tree nodes for  any LIR instruction that has > 2 "real" operands e.g., a CALL. We also mark nodes that must be tree roots.
 * @param dg  The dependence graph. 
 */
private void buildTrees(OPT_DepGraph dg){
  OPT_DepGraphNode bbNodes=(OPT_DepGraphNode)dg.firstNode();
  OPT_Instruction firstInstruction=bbNodes.instruction();
  for (OPT_DepGraphNode n=bbNodes; n != null; n=(OPT_DepGraphNode)n.getNext()) {
    OPT_BURS_TreeNode cur_parent=new OPT_BURS_TreeNode(n);
    n.scratchObject=cur_parent;
    OPT_Instruction instr=n.instruction();
    for (OPT_OperandEnumeration uses=instr.getUses(); uses.hasMoreElements(); ) {
      OPT_Operand op=uses.next();
      if (op == null)       continue;
      OPT_BURS_TreeNode child;
      if (op instanceof OPT_RegisterOperand) {
        OPT_RegisterOperand regOp=(OPT_RegisterOperand)op;
        if (regOp.register.isValidation())         continue;
        OPT_DepGraphEdge e=OPT_DepGraphEdge.findInputEdge(n,op);
        if (e == null) {
          child=Register;
        }
 else {
          child=(OPT_BURS_TreeNode)e.fromNode().scratchObject;
        }
      }
 else       if (op instanceof OPT_IntConstantOperand) {
        child=new OPT_BURS_IntConstantTreeNode(((OPT_IntConstantOperand)op).value);
      }
 else       if (op instanceof OPT_LongConstantOperand) {
        child=LongConstant;
      }
 else       if (op instanceof OPT_AddressConstantOperand) {
        child=AddressConstant;
      }
 else       if (op instanceof OPT_BranchOperand && instr.isCall()) {
        child=BranchTarget;
      }
 else       if (op instanceof OPT_InlinedOsrTypeInfoOperand && instr.isYieldPoint()) {
        child=NullTreeNode;
      }
 else {
        continue;
      }
      if (cur_parent.child1 == null) {
        cur_parent.child1=child;
      }
 else       if (cur_parent.child2 == null) {
        cur_parent.child2=child;
      }
 else {
        OPT_BURS_TreeNode child1=cur_parent.child2;
        OPT_BURS_TreeNode aux=new OPT_BURS_TreeNode(OTHER_OPERAND_opcode);
        cur_parent.child2=aux;
        cur_parent=aux;
        cur_parent.child1=child1;
        cur_parent.child2=child;
      }
    }
switch (instr.getOpcode()) {
case CALL_opcode:
case SYSCALL_opcode:
case YIELDPOINT_OSR_opcode:
      if (cur_parent.child2 == null)       cur_parent.child2=NullTreeNode;
case RETURN_opcode:
    if (cur_parent.child1 == null)     cur_parent.child1=NullTreeNode;
}
if (mustBeTreeRoot(n)) {
  makeTreeRoot((OPT_BURS_TreeNode)n.scratchObject);
}
}
}

Fixed version (ground truth):
/** 
 * Stage 1: Complete the expression trees and identify tree roots. Complete BURS trees by adding leaf nodes as needed, and creating tree edges by calling insertChild1() or insertChild2() This step is also where we introduce intermediate tree nodes for  any LIR instruction that has > 2 "real" operands e.g., a CALL. We also mark nodes that must be tree roots.
 * @param dg  The dependence graph. 
 */
private void buildTrees(OPT_DepGraph dg){
  OPT_DepGraphNode bbNodes=(OPT_DepGraphNode)dg.firstNode();
  for (OPT_DepGraphNode n=bbNodes; n != null; n=(OPT_DepGraphNode)n.getNext()) {
    OPT_BURS_TreeNode cur_parent=new OPT_BURS_TreeNode(n);
    n.scratchObject=cur_parent;
    OPT_Instruction instr=n.instruction();
    for (OPT_OperandEnumeration uses=instr.getUses(); uses.hasMoreElements(); ) {
      OPT_Operand op=uses.next();
      if (op == null)       continue;
      OPT_BURS_TreeNode child;
      if (op instanceof OPT_RegisterOperand) {
        OPT_RegisterOperand regOp=(OPT_RegisterOperand)op;
        if (regOp.register.isValidation())         continue;
        OPT_DepGraphEdge e=OPT_DepGraphEdge.findInputEdge(n,op);
        if (e == null) {
          child=Register;
        }
 else {
          child=(OPT_BURS_TreeNode)e.fromNode().scratchObject;
        }
      }
 else       if (op instanceof OPT_IntConstantOperand) {
        child=new OPT_BURS_IntConstantTreeNode(((OPT_IntConstantOperand)op).value);
      }
 else       if (op instanceof OPT_LongConstantOperand) {
        child=LongConstant;
      }
 else       if (op instanceof OPT_AddressConstantOperand) {
        child=AddressConstant;
      }
 else       if (op instanceof OPT_BranchOperand && instr.isCall()) {
        child=BranchTarget;
      }
 else       if (op instanceof OPT_InlinedOsrTypeInfoOperand && instr.isYieldPoint()) {
        child=NullTreeNode;
      }
 else {
        continue;
      }
      if (cur_parent.child1 == null) {
        cur_parent.child1=child;
      }
 else       if (cur_parent.child2 == null) {
        cur_parent.child2=child;
      }
 else {
        OPT_BURS_TreeNode child1=cur_parent.child2;
        OPT_BURS_TreeNode aux=new OPT_BURS_TreeNode(OTHER_OPERAND_opcode);
        cur_parent.child2=aux;
        cur_parent=aux;
        cur_parent.child1=child1;
        cur_parent.child2=child;
      }
    }
switch (instr.getOpcode()) {
case CALL_opcode:
case SYSCALL_opcode:
case YIELDPOINT_OSR_opcode:
      if (cur_parent.child2 == null)       cur_parent.child2=NullTreeNode;
case RETURN_opcode:
    if (cur_parent.child1 == null)     cur_parent.child1=NullTreeNode;
}
if (mustBeTreeRoot(n)) {
  makeTreeRoot((OPT_BURS_TreeNode)n.scratchObject);
}
}
}