LV code on machine instructions


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/LiveVar/LiveVarSet.cpp b/lib/Analysis/LiveVar/LiveVarSet.cpp
index c893817..07dc128 100644
--- a/lib/Analysis/LiveVar/LiveVarSet.cpp
+++ b/lib/Analysis/LiveVar/LiveVarSet.cpp
@@ -1,9 +1,42 @@
 #include "llvm/Analysis/LiveVar/LiveVarSet.h"
+#include "llvm/CodeGen/MachineInstr.h"
 
 
-// This function applies an instruction to a live var set (accepts OutSet) and
-//  makes necessary changes to it (produces InSet)
+// This function applies a machine instr to a live var set (accepts OutSet) and
+// makes necessary changes to it (produces InSet). Note that two for loops are
+// used to first kill all defs and then to add all uses. This is because there
+// can be instructions like Val = Val + 1 since we allow multipe defs to a 
+// machine instruction operand.
 
+
+void LiveVarSet::applyTranferFuncForMInst(const MachineInstr *const MInst)
+{
+
+  for( MachineInstr::val_op_const_iterator OpI(MInst); !OpI.done() ; OpI++) {
+
+    if( OpI.isDef() ) {     // kill only if this operand is a def
+         remove(*OpI);        // this definition kills any uses
+    }
+
+  }
+
+  for( MachineInstr::val_op_const_iterator OpI(MInst); !OpI.done() ; OpI++) {
+
+    if ( ((*OpI)->getType())->isLabelType()) continue; // don't process labels
+
+    if( ! OpI.isDef() ) {     // add only if this operand is a use
+       add( *OpI );            // An operand is a use - so add to use set
+    }
+  }
+}
+
+  
+
+
+
+
+
+#if 0
 void LiveVarSet::applyTranferFuncForInst(const Instruction *const Inst) 
 {
 
@@ -18,3 +51,4 @@
   }
 
 }
+#endif