Immediately erase trivially useless copies.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Sat, 19 May 2012 05:25:53 +0000 (05:25 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Sat, 19 May 2012 05:25:53 +0000 (05:25 +0000)
There is no need for these instructions to stick around since they are
known to be not dead.

llvm-svn: 157102

llvm/lib/CodeGen/RegisterCoalescer.cpp

index 84fd590..0dbc7b6 100644 (file)
@@ -1070,15 +1070,17 @@ bool RegisterCoalescer::joinCopy(MachineInstr *CopyMI, bool &Again) {
 
   // If they are already joined we continue.
   if (CP.getSrcReg() == CP.getDstReg()) {
-    markAsJoined(CopyMI);
     DEBUG(dbgs() << "\tCopy already coalesced.\n");
+    LIS->RemoveMachineInstrFromMaps(CopyMI);
+    CopyMI->eraseFromParent();
     return false;  // Not coalescable.
   }
 
   // Eliminate undefs.
   if (!CP.isPhys() && eliminateUndefCopy(CopyMI, CP)) {
-    markAsJoined(CopyMI);
     DEBUG(dbgs() << "\tEliminated copy of <undef> value.\n");
+    LIS->RemoveMachineInstrFromMaps(CopyMI);
+    CopyMI->eraseFromParent();
     return false;  // Not coalescable.
   }