Don't add the same MI to register reuse "last def/use" twice if it reads the
authorEvan Cheng <evan.cheng@apple.com>
Fri, 30 Mar 2007 20:21:35 +0000 (20:21 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Fri, 30 Mar 2007 20:21:35 +0000 (20:21 +0000)
register more than once.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35513 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/VirtRegMap.cpp

index 2532fa31c845a78bbfbe70aadf94f73c89cbaed4..d651f9d05f14d1d54b761b3de8d179448e4831e6 100644 (file)
@@ -316,7 +316,9 @@ public:
       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 @@ void LocalSpiller::RewriteMBB(MachineBasicBlock &MBB, VirtRegMap &VRM,
           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;