Fix a bug in my previous patch, grabbing the shift amount width from the
[oota-llvm.git] / lib / CodeGen / MachineInstr.cpp
index 01a3e3ee381a172d59f442dde4b6bdff3dc16b82..a1e76916f1df0d2e9cc321928615845c69cdcd48 100644 (file)
@@ -170,14 +170,16 @@ bool MachineOperand::isIdenticalTo(const MachineOperand &Other) const {
 }
 
 /// findRegisterUseOperand() - Returns the MachineOperand that is a use of
-/// the specific register or NULL if it is not found.
-MachineOperand *MachineInstr::findRegisterUseOperand(unsigned Reg) {
+/// the specific register or -1 if it is not found. It further tightening
+/// the search criteria to a use that kills the register if isKill is true.
+int MachineInstr::findRegisterUseOperand(unsigned Reg, bool isKill){
   for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
     MachineOperand &MO = getOperand(i);
     if (MO.isReg() && MO.isUse() && MO.getReg() == Reg)
-      return &MO;
+      if (!isKill || MO.isKill())
+        return i;
   }
-  return NULL;
+  return -1;
 }
   
 /// findRegisterDefOperand() - Returns the MachineOperand that is a def of