static void eliminateDeadInstructions(OPT_IR ir, boolean preserveImplicitSSA) {  for (OPT_Instruction instr = ir.lastInstructionInCodeOrder(), prevInstr = null; instr != null; instr = prevInstr) { prevInstr = instr.prevInstructionInCodeOrder();   if (instr.isPEI() || instr.isImplicitStore() || instr.isBranch() || instr.isCall()) continue; if (preserveImplicitSSA && (instr.isImplicitLoad() || instr.isAllocation() || instr.operator() == PHI)) continue;   if (instr.operator() == NOP) { OPT_DefUse.removeInstructionAndUpdateDU(instr); }   if (instr.operator() == UNINT_BEGIN) { OPT_Instruction s = instr.nextInstructionInCodeOrder(); if (s.operator() == UNINT_END) { OPT_DefUse.removeInstructionAndUpdateDU(s); OPT_DefUse.removeInstructionAndUpdateDU(instr); } }   if (Move.conforms(instr)) { OPT_Register lhs = Move.getResult(instr).asRegister().register; if (Move.getVal(instr).isRegister()) { OPT_Register rhs = Move.getVal(instr).asRegister().register; if (lhs == rhs) { OPT_DefUse.removeInstructionAndUpdateDU(instr); continue; } } }   boolean isDead = true; boolean foundRegisterDef = false; for (OPT_OperandEnumeration defs = instr.getDefs(); defs.hasMoreElements();) { OPT_Operand def = (OPT_Operand)defs.nextElement(); if (!def.isRegister()) { isDead = false; break; } foundRegisterDef = true; OPT_RegisterOperand r = def.asRegister(); if (r.register.useList != null) { isDead = false; break; } ; if (r.register.isPhysical()) { isDead = false; break; } } if (!isDead) continue; if (!foundRegisterDef) continue;   OPT_DefUse.removeInstructionAndUpdateDU(instr); }
static void eliminateDeadInstructions (OPT_IR ir) { eliminateDeadInstructions(ir, false);
  static void eliminateDeadInstructions(OPT_IR ir,                                         boolean preserveImplicitSSA) {    // (USE BACKWARDS PASS FOR INCREASED EFFECTIVENESS)    for (OPT_Instruction instr = ir.lastInstructionInCodeOrder(),         prevInstr = null;         instr != null; instr = prevInstr) {      prevInstr = instr.prevInstructionInCodeOrder(); // cache because                                         // remove nulls next/prev fields      // if instr is a PEI, store, branch, or call, then it's not dead ...      if (instr.isPEI() || instr.isImplicitStore() || instr.isBranch()          || instr.isCall())        continue;      if (preserveImplicitSSA && (instr.isImplicitLoad() || instr.isAllocation()          || instr.operator() == PHI))        continue;      // remove NOPs      if (instr.operator() == NOP) {        OPT_DefUse.removeInstructionAndUpdateDU(instr);      }            // remove UNINT_BEGIN/UNINT_END with nothing in between them      if (instr.operator() == UNINT_BEGIN) {        OPT_Instruction s = instr.nextInstructionInCodeOrder();        if (s.operator() == UNINT_END) {          OPT_DefUse.removeInstructionAndUpdateDU(s);          OPT_DefUse.removeInstructionAndUpdateDU(instr);        }      }      // remove trivial assignments      if (Move.conforms(instr)) {        OPT_Register lhs = Move.getResult(instr).asRegister().register;        if (Move.getVal(instr).isRegister()) {          OPT_Register rhs = Move.getVal(instr).asRegister().register;          if (lhs == rhs) {            OPT_DefUse.removeInstructionAndUpdateDU(instr);            continue;          }        }      }      // check that all defs are to dead registers and that       // there is at least 1 def.      boolean isDead = true;      boolean foundRegisterDef = false;      for (OPT_OperandEnumeration defs = instr.getDefs();           defs.hasMoreElements();) {        OPT_Operand def = (OPT_Operand)defs.nextElement();        if (!def.isRegister()) {          isDead = false;          break;        }        foundRegisterDef = true;        OPT_RegisterOperand r = def.asRegister();        if (r.register.useList != null) {          isDead = false;          break;        }        ;        if (r.register.isPhysical()) {          isDead = false;          break;        }      }      if (!isDead)        continue;      if (!foundRegisterDef)        continue;      // There are 1 or more register defs, but all of them are dead.       // Remove instr.      OPT_DefUse.removeInstructionAndUpdateDU(instr);    }  }