Another coalescer bug. When a dead copy is eliminated, transfer the kill to a def...
authorEvan Cheng <evan.cheng@apple.com>
Fri, 7 Aug 2009 07:14:14 +0000 (07:14 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Fri, 7 Aug 2009 07:14:14 +0000 (07:14 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78376 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SimpleRegisterCoalescing.cpp
test/CodeGen/Thumb2/2009-08-07-CoalescerBug.ll [new file with mode: 0644]

index b57bbc2ca5ebd15fd9a4393e487e326060552a06..5688d8d6cff36d409a33d5525911895700646d60 100644 (file)
@@ -888,12 +888,13 @@ static void PropagateDeadness(LiveInterval &li, MachineInstr *CopyMI,
   MachineInstr *DefMI =
     li_->getInstructionFromIndex(li_->getDefIndex(LRStart));
   if (DefMI && DefMI != CopyMI) {
-    int DeadIdx = DefMI->findRegisterDefOperandIdx(li.reg, false, tri_);
-    if (DeadIdx != -1) {
+    int DeadIdx = DefMI->findRegisterDefOperandIdx(li.reg, false);
+    if (DeadIdx != -1)
       DefMI->getOperand(DeadIdx).setIsDead();
-      // A dead def should have a single cycle interval.
-      ++LRStart;
-    }
+    else
+      DefMI->addOperand(MachineOperand::CreateReg(li.reg,
+                                                  true, true, false, true));
+    ++LRStart;
   }
 }
 
diff --git a/test/CodeGen/Thumb2/2009-08-07-CoalescerBug.ll b/test/CodeGen/Thumb2/2009-08-07-CoalescerBug.ll
new file mode 100644 (file)
index 0000000..4cd5b1e
--- /dev/null
@@ -0,0 +1,16 @@
+; RUN: llvm-as < %s | llc -mtriple=armv7-eabi -mattr=+vfp2
+; PR4686
+
+       %a = type { i32 (...)** }
+       %b = type { %a }
+       %c = type { float, float, float, float }
+
+declare arm_aapcs_vfpcc float @bar(%c*)
+
+define arm_aapcs_vfpcc void @foo(%b* %x, %c* %y) {
+entry:
+       %0 = call arm_aapcs_vfpcc  float @bar(%c* %y)           ; <float> [#uses=0]
+       %1 = fadd float undef, undef            ; <float> [#uses=1]
+       store float %1, float* undef, align 8
+       ret void
+}