[llvm-commits] [llvm] r65214 - /llvm/branches/Apple/Dib/lib/Target/X86/X86RegisterInfo.cpp

Bill Wendling isanbard at gmail.com
Fri Feb 20 17:17:22 PST 2009


Author: void
Date: Fri Feb 20 19:17:22 2009
New Revision: 65214

URL: http://llvm.org/viewvc/llvm-project?rev=65214&view=rev
Log:
Pull r65206, r65207, r65211, and r65213 into Dib:

Propagate debug location info through the prologue/epilogue stuff.

Modified:
    llvm/branches/Apple/Dib/lib/Target/X86/X86RegisterInfo.cpp

Modified: llvm/branches/Apple/Dib/lib/Target/X86/X86RegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/Target/X86/X86RegisterInfo.cpp?rev=65214&r1=65213&r2=65214&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/lib/Target/X86/X86RegisterInfo.cpp (original)
+++ llvm/branches/Apple/Dib/lib/Target/X86/X86RegisterInfo.cpp Fri Feb 20 19:17:22 2009
@@ -542,8 +542,8 @@
        (Is64Bit ? X86::ADD64ri8 : X86::ADD32ri8) :
        (Is64Bit ? X86::ADD64ri32 : X86::ADD32ri));
   uint64_t Chunk = (1LL << 31) - 1;
-  // We could pass in a DebugLoc, but this is only called from prolog/epilog.
-  DebugLoc DL = DebugLoc::getUnknownLoc();
+  DebugLoc DL = (MBBI != MBB.end() ? MBBI->getDebugLoc() :
+                 DebugLoc::getUnknownLoc());
 
   while (Offset) {
     uint64_t ThisVal = (Offset > Chunk) ? Chunk : Offset;
@@ -729,12 +729,15 @@
   bool needsFrameMoves = (MMI && MMI->hasDebugInfo()) ||
                           !Fn->doesNotThrow() ||
                           UnwindTablesMandatory;
-  DebugLoc DL = DebugLoc::getUnknownLoc();
+  DebugLoc DL = (MBBI != MBB.end() ? MBBI->getDebugLoc() :
+                 DebugLoc::getUnknownLoc());
+
   // Prepare for frame info.
   unsigned FrameLabelId = 0;
 
   // Get the number of bytes to allocate from the FrameInfo.
   uint64_t StackSize = MFI->getStackSize();
+
   // Get desired stack alignment
   uint64_t MaxAlign  = MFI->getMaxAlignment();
 
@@ -813,8 +816,9 @@
       // The EFLAGS implicit def is dead.
       MI->getOperand(3).setIsDead();
     }
-  } else
+  } else {
     NumBytes = StackSize - X86FI->getCalleeSavedFrameSize();
+  }
 
   unsigned ReadyLabelId = 0;
   if (needsFrameMoves) {
@@ -829,6 +833,9 @@
           MBBI->getOpcode() == X86::PUSH64r))
     ++MBBI;
 
+  if (MBBI != MBB.end())
+    DL = MBBI->getDebugLoc();
+
   if (NumBytes) {   // adjust stack pointer: ESP -= numbytes
     if (NumBytes >= 4096 && Subtarget->isTargetCygMing()) {
       // Check, whether EAX is livein for this function
@@ -846,7 +853,8 @@
       // necessary to ensure that the guard pages used by the OS virtual memory
       // manager are allocated in correct sequence.
       if (!isEAXAlive) {
-        BuildMI(MBB, MBBI,DL, TII.get(X86::MOV32ri), X86::EAX).addImm(NumBytes);
+        BuildMI(MBB, MBBI, DL, TII.get(X86::MOV32ri), X86::EAX)
+          .addImm(NumBytes);
         BuildMI(MBB, MBBI, DL, TII.get(X86::CALLpcrel32))
           .addExternalSymbol("_alloca");
       } else {
@@ -889,7 +897,7 @@
   X86MachineFunctionInfo *X86FI = MF.getInfo<X86MachineFunctionInfo>();
   MachineBasicBlock::iterator MBBI = prior(MBB.end());
   unsigned RetOpcode = MBBI->getOpcode();
-  DebugLoc DL = DebugLoc::getUnknownLoc();
+  DebugLoc DL = MBBI->getDebugLoc();
 
   switch (RetOpcode) {
   case X86::RET:
@@ -922,10 +930,11 @@
     NumBytes = FrameSize - CSSize;
 
     // pop EBP.
-    BuildMI(MBB, MBBI, DL, 
+    BuildMI(MBB, MBBI, DL,
             TII.get(Is64Bit ? X86::POP64r : X86::POP32r), FramePtr);
-  } else
+  } else {
     NumBytes = StackSize - CSSize;
+  }
 
   // Skip the callee-saved pop instructions.
   MachineBasicBlock::iterator LastCSPop = MBBI;
@@ -938,6 +947,8 @@
     --MBBI;
   }
 
+  DL = MBBI->getDebugLoc();
+
   // If there is an ADD32ri or SUB32ri of ESP immediately before this
   // instruction, merge the two instructions.
   if (NumBytes || MFI->hasVarSizedObjects())
@@ -997,19 +1008,22 @@
     // Incoporate the retaddr area.
     Offset = StackAdj-MaxTCDelta;
     assert(Offset >= 0 && "Offset should never be negative");
+
     if (Offset) {
       // Check for possible merge with preceeding ADD instruction.
       Offset += mergeSPUpdates(MBB, MBBI, StackPtr, true);
       emitSPUpdate(MBB, MBBI, StackPtr, Offset, Is64Bit, TII);
     }
+
     // Jump to label or value in register.
     if (RetOpcode == X86::TCRETURNdi|| RetOpcode == X86::TCRETURNdi64)
       BuildMI(MBB, MBBI, DL, TII.get(X86::TAILJMPd)).
         addGlobalAddress(JumpTarget.getGlobal(), JumpTarget.getOffset());
-    else if (RetOpcode== X86::TCRETURNri64) {
+    else if (RetOpcode== X86::TCRETURNri64)
       BuildMI(MBB, MBBI, DL, TII.get(X86::TAILJMPr64), JumpTarget.getReg());
-    } else
+    else
        BuildMI(MBB, MBBI, DL, TII.get(X86::TAILJMPr), JumpTarget.getReg());
+
     // Delete the pseudo instruction TCRETURN.
     MBB.erase(MBBI);
   } else if ((RetOpcode == X86::RET || RetOpcode == X86::RETI) &&





More information about the llvm-commits mailing list