[llvm-commits] [llvm] r84153 - in /llvm/trunk: lib/CodeGen/LiveVariables.cpp test/CodeGen/X86/2009-10-14-LiveVariablesBug.ll

Evan Cheng evan.cheng at apple.com
Wed Oct 14 16:39:28 PDT 2009


Author: evancheng
Date: Wed Oct 14 18:39:27 2009
New Revision: 84153

URL: http://llvm.org/viewvc/llvm-project?rev=84153&view=rev
Log:
When LiveVariables is adding implicit-def to model "partial dead", add the earlyclobber marker if the superreg def has it.

Added:
    llvm/trunk/test/CodeGen/X86/2009-10-14-LiveVariablesBug.ll
Modified:
    llvm/trunk/lib/CodeGen/LiveVariables.cpp

Modified: llvm/trunk/lib/CodeGen/LiveVariables.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveVariables.cpp?rev=84153&r1=84152&r2=84153&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/LiveVariables.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveVariables.cpp Wed Oct 14 18:39:27 2009
@@ -323,10 +323,21 @@
       // The last partial def kills the register.
       LastPartDef->addOperand(MachineOperand::CreateReg(Reg, false/*IsDef*/,
                                                 true/*IsImp*/, true/*IsKill*/));
-    else
+    else {
+      MachineOperand *MO =
+        LastRefOrPartRef->findRegisterDefOperand(Reg, false, TRI);
+      bool NeedEC = MO->isEarlyClobber() && MO->getReg() != Reg;
       // If the last reference is the last def, then it's not used at all.
       // That is, unless we are currently processing the last reference itself.
       LastRefOrPartRef->addRegisterDead(Reg, TRI, true);
+      if (NeedEC) {
+        // If we are adding a subreg def and the superreg def is marked early
+        // clobber, add an early clobber marker to the subreg def.
+        MO = LastRefOrPartRef->findRegisterDefOperand(Reg);
+        if (MO)
+          MO->setIsEarlyClobber();
+      }
+    }
   } else if (!PhysRegUse[Reg]) {
     // Partial uses. Mark register def dead and add implicit def of
     // sub-registers which are used.

Added: llvm/trunk/test/CodeGen/X86/2009-10-14-LiveVariablesBug.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/2009-10-14-LiveVariablesBug.ll?rev=84153&view=auto

==============================================================================
--- llvm/trunk/test/CodeGen/X86/2009-10-14-LiveVariablesBug.ll (added)
+++ llvm/trunk/test/CodeGen/X86/2009-10-14-LiveVariablesBug.ll Wed Oct 14 18:39:27 2009
@@ -0,0 +1,15 @@
+; RUN: llc < %s -mtriple=i386-apple-darwin
+; rdar://7299435
+
+ at i = internal global i32 0                        ; <i32*> [#uses=1]
+ at llvm.used = appending global [1 x i8*] [i8* bitcast (void (i16)* @foo to i8*)], section "llvm.metadata" ; <[1 x i8*]*> [#uses=0]
+
+define void @foo(i16 signext %source) nounwind ssp {
+entry:
+  %source_addr = alloca i16, align 2              ; <i16*> [#uses=2]
+  store i16 %source, i16* %source_addr
+  store i32 4, i32* @i, align 4
+  call void asm sideeffect "# top of block", "~{dirflag},~{fpsr},~{flags},~{edi},~{esi},~{edx},~{ecx},~{eax}"() nounwind
+  %asmtmp = call i16 asm sideeffect "movw $1, $0", "=={ax},*m,~{dirflag},~{fpsr},~{flags},~{memory}"(i16* %source_addr) nounwind ; <i16> [#uses=0]
+  ret void
+}





More information about the llvm-commits mailing list