Also add <def,undef> flags when coalescing sub-registers.
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Wed, 5 Oct 2011 00:01:46 +0000 (00:01 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Wed, 5 Oct 2011 00:01:46 +0000 (00:01 +0000)
RegisterCoalescer can create sub-register defs when it is joining a
register with a sub-register.  Add <undef> flags to these new
sub-register defs where appropriate.

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

lib/CodeGen/RegisterCoalescer.cpp

index 990ef370bb3f89cbe8781c80c41b665a9a94e0b7..361ae7a63f0588b7c3f4a34729aaa96490a73f6f 100644 (file)
@@ -967,6 +967,14 @@ RegisterCoalescer::UpdateRegDefsUses(const CoalescerPair &CP) {
       Kills |= MO.isKill();
       Deads |= MO.isDead();
 
+      // Make sure we don't create read-modify-write defs accidentally.  We
+      // assume here that a SrcReg def cannot be joined into a live DstReg.  If
+      // RegisterCoalescer starts tracking partially live registers, we will
+      // need to check the actual LiveInterval to determine if DstReg is live
+      // here.
+      if (SubIdx && !Reads)
+        MO.setIsUndef();
+
       if (DstIsPhys)
         MO.substPhysReg(DstReg, *TRI);
       else