Don't completely eliminate identity copies that also modify super register liveness.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Thu, 31 Mar 2011 17:55:25 +0000 (17:55 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Thu, 31 Mar 2011 17:55:25 +0000 (17:55 +0000)
Turn them into noop KILL instructions instead. This lets the scavenger know when
super-registers are killed and defined.

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

lib/CodeGen/VirtRegMap.cpp
test/CodeGen/Blackfin/2009-08-04-LowerExtract-Live.ll

index 61d6ac88ed89c00420f6ef3fe7aace11521d4780..7a7ea69e27fca567ad9ccbe04dbe2dacf1c43c5c 100644 (file)
@@ -309,12 +309,18 @@ void VirtRegMap::rewrite(SlotIndexes *Indexes) {
 
       // Finally, remove any identity copies.
       if (MI->isIdentityCopy()) {
-        DEBUG(dbgs() << "Deleting identity copy.\n");
-        RemoveMachineInstrFromMaps(MI);
-        if (Indexes)
-          Indexes->removeMachineInstrFromMaps(MI);
-        // It's safe to erase MI because MII has already been incremented.
-        MI->eraseFromParent();
+        if (MI->getNumOperands() == 2) {
+          DEBUG(dbgs() << "Deleting identity copy.\n");
+          RemoveMachineInstrFromMaps(MI);
+          if (Indexes)
+            Indexes->removeMachineInstrFromMaps(MI);
+          // It's safe to erase MI because MII has already been incremented.
+          MI->eraseFromParent();
+        } else {
+          // Transform identity copy to a KILL to deal with subregisters.
+          MI->setDesc(TII->get(TargetOpcode::KILL));
+          DEBUG(dbgs() << "Identity copy: " << *MI);
+        }
       }
     }
   }
index 3ee5e8df9972f8e5335679985aca51330082eca2..50fccb440990b438e12641ce0b195c1460322de6 100644 (file)
@@ -1,4 +1,5 @@
 ; RUN: llc < %s -march=bfin -join-liveintervals=0 -verify-machineinstrs
+; RUN: llc < %s -march=bfin -join-liveintervals=0 -verify-machineinstrs -regalloc=greedy
 
 ; Provoke an error in LowerSubregsPass::LowerExtract where the live range of a
 ; super-register is illegally extended.