- Each val# can have multiple kills.
- Fix some minor bugs related to special markers on val# def. ~0U means
  undefined, ~1U means dead val#.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@40916 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/LiveInterval.cpp b/lib/CodeGen/LiveInterval.cpp
index a11a8f5..580cf44 100644
--- a/lib/CodeGen/LiveInterval.cpp
+++ b/lib/CodeGen/LiveInterval.cpp
@@ -300,7 +300,7 @@
   // we want to avoid the interval scan if not.
   bool MustMapCurValNos = false;
   for (unsigned i = 0, e = getNumValNums(); i != e; ++i) {
-    if (ValueNumberInfo[i].def == ~1U) continue;  // tombstone value #
+    //if (ValueNumberInfo[i].def == ~1U) continue;  // tombstone value #
     if (i != (unsigned)LHSValNoAssignments[i]) {
       MustMapCurValNos = true;
       break;
@@ -508,14 +508,11 @@
       OS << i << "@";
       if (ValueNumberInfo[i].def == ~0U) {
         OS << "?";
+      } else if (ValueNumberInfo[i].def == ~1U) {
+        OS << "x";
       } else {
         OS << ValueNumberInfo[i].def;
       }
-      if (ValueNumberInfo[i].kill == ~0U) {
-        OS << ",?";
-      } else {
-        OS << "," << ValueNumberInfo[i].kill;
-      }
     }
   }
 }
diff --git a/lib/CodeGen/LiveIntervalAnalysis.cpp b/lib/CodeGen/LiveIntervalAnalysis.cpp
index c17f2ac..c286a1a 100644
--- a/lib/CodeGen/LiveIntervalAnalysis.cpp
+++ b/lib/CodeGen/LiveIntervalAnalysis.cpp
@@ -347,7 +347,6 @@
 
     // Get the Idx of the defining instructions.
     unsigned defIndex = getDefIndex(MIIdx);
-
     unsigned ValNum;
     unsigned SrcReg, DstReg;
     if (!tii_->isMoveInstr(*mi, SrcReg, DstReg))
@@ -378,6 +377,7 @@
         LiveRange LR(defIndex, killIdx, ValNum);
         interval.addRange(LR);
         DOUT << " +" << LR << "\n";
+        interval.addKillForValNum(ValNum, killIdx);
         return;
       }
     }
@@ -412,10 +412,11 @@
     // block to the 'use' slot of the killing instruction.
     for (unsigned i = 0, e = vi.Kills.size(); i != e; ++i) {
       MachineInstr *Kill = vi.Kills[i];
+      unsigned killIdx = getUseIndex(getInstructionIndex(Kill))+1;
       LiveRange LR(getMBBStartIdx(Kill->getParent()),
-                   getUseIndex(getInstructionIndex(Kill))+1,
-                   ValNum);
+                   killIdx, ValNum);
       interval.addRange(LR);
+      interval.addKillForValNum(ValNum, killIdx);
       DOUT << " +" << LR;
     }
 
@@ -450,7 +451,7 @@
       interval.setValueNumberInfo(1, interval.getValNumInfo(0));
       
       // Value#0 is now defined by the 2-addr instruction.
-      interval.setValueNumberInfo(0, LiveInterval::VNInfo(DefIndex, ~0U, 0U));
+      interval.setValueNumberInfo(0, LiveInterval::VNInfo(DefIndex, 0U));
       
       // Add the new live interval which replaces the range for the input copy.
       LiveRange LR(DefIndex, RedefIndex, ValNo);
diff --git a/lib/CodeGen/SimpleRegisterCoalescing.cpp b/lib/CodeGen/SimpleRegisterCoalescing.cpp
index a37a005..cead5e5 100644
--- a/lib/CodeGen/SimpleRegisterCoalescing.cpp
+++ b/lib/CodeGen/SimpleRegisterCoalescing.cpp
@@ -132,7 +132,7 @@
   // We are about to delete CopyMI, so need to remove it as the 'instruction
   // that defines this value #'. Update the the valnum with the new defining
   // instruction #.
-  IntB.setValueNumberInfo(BValNo, LiveInterval::VNInfo(FillerStart, ~0U, 0));
+  IntB.setValueNumberInfo(BValNo, LiveInterval::VNInfo(FillerStart, 0));
   
   // Okay, we can merge them.  We need to insert a new liverange:
   // [ValLR.end, BLR.begin) of either value number, then we merge the
@@ -645,7 +645,7 @@
           // Otherwise, use the specified value #.
           LHSValNoAssignments[VN] = RHSValID;
           if (VN != (unsigned)RHSValID)
-            ValueNumberInfo[VN].def = ~1U;
+            ValueNumberInfo[VN].def = RHSValNoInfo.def;
           else
             ValueNumberInfo[VN] = RHSValNoInfo;
         }