]> granicus.if.org Git - llvm/commitdiff
Emit pseudo instructions to indicate that some registers are live on entrance
authorChris Lattner <sabre@nondot.org>
Tue, 6 May 2003 21:32:22 +0000 (21:32 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 6 May 2003 21:32:22 +0000 (21:32 +0000)
and exit of the function.  This fixes bug: Jello/2003-05-06-LivenessClobber.llx
and the Fhourstones benchmark

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

lib/Target/X86/InstSelectSimple.cpp
lib/Target/X86/X86ISelSimple.cpp

index a65a42737efd49722da4575dfd58940a70fd468c..3a12d5e2c9c6115f9bac4c0cb82c94042852eae4 100644 (file)
@@ -78,6 +78,11 @@ namespace {
         F->getBasicBlockList().push_back(MBBMap[I] = new MachineBasicBlock(I));
 
       BB = &F->front();
+
+      // Declare that the stack pointer is live on entrance to the function
+      BuildMI(BB, X86::IMPLICIT_DEF, 0, X86::ESP);
+
+      // Copy incoming arguments off of the stack...
       LoadArgumentsToVirtualRegs(Fn);
 
       // Instruction select everything except PHI nodes
@@ -671,13 +676,19 @@ void ISel::visitReturnInst(ReturnInst &I) {
   case cShort:
   case cInt:
     promote32(X86::EAX, ValueRecord(RetReg, RetVal->getType()));
+    // Declare that EAX is live on exit
+    BuildMI(BB, X86::IMPLICIT_USE, 1).addReg(X86::EAX);
     break;
   case cFP:                   // Floats & Doubles: Return in ST(0)
     BuildMI(BB, X86::FpSETRESULT, 1).addReg(RetReg);
+    // Declare that top-of-stack is live on exit
+    BuildMI(BB, X86::IMPLICIT_USE, 1).addReg(X86::ST0);
     break;
   case cLong:
     BuildMI(BB, X86::MOVrr32, 1, X86::EAX).addReg(RetReg);
     BuildMI(BB, X86::MOVrr32, 1, X86::EDX).addReg(RetReg+1);
+    // Declare that EAX & EDX are live on exit
+    BuildMI(BB, X86::IMPLICIT_USE, 2).addReg(X86::EAX).addReg(X86::EDX);
     break;
   default:
     visitInstruction(I);
index a65a42737efd49722da4575dfd58940a70fd468c..3a12d5e2c9c6115f9bac4c0cb82c94042852eae4 100644 (file)
@@ -78,6 +78,11 @@ namespace {
         F->getBasicBlockList().push_back(MBBMap[I] = new MachineBasicBlock(I));
 
       BB = &F->front();
+
+      // Declare that the stack pointer is live on entrance to the function
+      BuildMI(BB, X86::IMPLICIT_DEF, 0, X86::ESP);
+
+      // Copy incoming arguments off of the stack...
       LoadArgumentsToVirtualRegs(Fn);
 
       // Instruction select everything except PHI nodes
@@ -671,13 +676,19 @@ void ISel::visitReturnInst(ReturnInst &I) {
   case cShort:
   case cInt:
     promote32(X86::EAX, ValueRecord(RetReg, RetVal->getType()));
+    // Declare that EAX is live on exit
+    BuildMI(BB, X86::IMPLICIT_USE, 1).addReg(X86::EAX);
     break;
   case cFP:                   // Floats & Doubles: Return in ST(0)
     BuildMI(BB, X86::FpSETRESULT, 1).addReg(RetReg);
+    // Declare that top-of-stack is live on exit
+    BuildMI(BB, X86::IMPLICIT_USE, 1).addReg(X86::ST0);
     break;
   case cLong:
     BuildMI(BB, X86::MOVrr32, 1, X86::EAX).addReg(RetReg);
     BuildMI(BB, X86::MOVrr32, 1, X86::EDX).addReg(RetReg+1);
+    // Declare that EAX & EDX are live on exit
+    BuildMI(BB, X86::IMPLICIT_USE, 2).addReg(X86::EAX).addReg(X86::EDX);
     break;
   default:
     visitInstruction(I);