Don't add the same MI to register reuse "last def/use" twice if it reads the
register more than once.

llvm-svn: 35513
diff --git a/llvm/lib/CodeGen/VirtRegMap.cpp b/llvm/lib/CodeGen/VirtRegMap.cpp
index 2532fa3..d651f9d 100644
--- a/llvm/lib/CodeGen/VirtRegMap.cpp
+++ b/llvm/lib/CodeGen/VirtRegMap.cpp
@@ -316,7 +316,9 @@
       assert(II != SpillSlotsAvailable.end() && "Slot not available!");
       unsigned Val = II->second.first;
       assert((Val >> 1) == PhysReg && "Bidirectional map mismatch!");
-      II->second.second.push_back(Use);
+      // This can be true if there are multiple uses of the same register.
+      if (II->second.second.back() != Use)
+        II->second.second.push_back(Use);
     }
   }
   
@@ -1117,6 +1119,7 @@
           if (TII->isMoveInstr(MI, Src, Dst) && Src == Dst) {
             ++NumDCE;
             DOUT << "Removing now-noop copy: " << MI;
+            Spills.removeLastUse(Src, &MI);
             MBB.erase(&MI);
             VRM.RemoveFromFoldedVirtMap(&MI);
             goto ProcessNextInst;