[llvm-commits] [llvm] r46635 - in /llvm/trunk: include/llvm/CodeGen/AsmPrinter.h lib/CodeGen/AsmPrinter.cpp lib/CodeGen/DwarfWriter.cpp lib/CodeGen/PrologEpilogInserter.cpp lib/CodeGen/SelectionDAG/ScheduleDAG.cpp lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp lib/Target/PowerPC/PPCRegisterInfo.cpp lib/Target/X86/X86RegisterInfo.cpp

Evan Cheng evan.cheng at apple.com
Fri Feb 1 01:10:45 PST 2008


Author: evancheng
Date: Fri Feb  1 03:10:45 2008
New Revision: 46635

URL: http://llvm.org/viewvc/llvm-project?rev=46635&view=rev
Log:
Remove the nasty LABEL hack with a much less evil one. Now llvm.dbg.func.start implies a stoppoint is set. SelectionDAGISel records a new source line but does not create a ISD::LABEL node for this special stoppoint. Asm printer will magically print this label. This ensures nothing is emitted before.

Modified:
    llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
    llvm/trunk/lib/CodeGen/AsmPrinter.cpp
    llvm/trunk/lib/CodeGen/DwarfWriter.cpp
    llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
    llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp
    llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp

Modified: llvm/trunk/include/llvm/CodeGen/AsmPrinter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/AsmPrinter.h?rev=46635&r1=46634&r2=46635&view=diff

==============================================================================
--- llvm/trunk/include/llvm/CodeGen/AsmPrinter.h (original)
+++ llvm/trunk/include/llvm/CodeGen/AsmPrinter.h Fri Feb  1 03:10:45 2008
@@ -276,6 +276,11 @@
                        unsigned ForcedAlignBits = 0, bool UseFillExpr = false,
                        unsigned FillValue = 0) const;
 
+    /// printLabel - This method prints a local label used by debug and
+    /// exception handling tables.
+    void printLabel(const MachineInstr *MI) const;
+    void printLabel(unsigned Id) const;
+
   protected:
     /// EmitZeros - Emit a block of zeros.
     ///
@@ -299,10 +304,6 @@
     /// instruction that is an inline asm.
     void printInlineAsm(const MachineInstr *MI) const;
     
-    /// printLabel - This method prints a local label used by debug and
-    /// exception handling tables.
-    void printLabel(const MachineInstr *MI) const;
-
     /// printBasicBlockLabel - This method prints the label for the specified
     /// MachineBasicBlock
     virtual void printBasicBlockLabel(const MachineBasicBlock *MBB,

Modified: llvm/trunk/lib/CodeGen/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter.cpp?rev=46635&r1=46634&r2=46635&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter.cpp Fri Feb  1 03:10:45 2008
@@ -1285,6 +1285,10 @@
     << "label" << MI->getOperand(0).getImm() << ":\n";
 }
 
+void AsmPrinter::printLabel(unsigned Id) const {
+  O << "\n" << TAI->getPrivateGlobalPrefix() << "label" << Id << ":\n";
+}
+
 /// PrintAsmOperand - Print the specified operand of MI, an INLINEASM
 /// instruction, using the specified assembler variant.  Targets should
 /// overried this to format as appropriate.

Modified: llvm/trunk/lib/CodeGen/DwarfWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/DwarfWriter.cpp?rev=46635&r1=46634&r2=46635&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/DwarfWriter.cpp (original)
+++ llvm/trunk/lib/CodeGen/DwarfWriter.cpp Fri Feb  1 03:10:45 2008
@@ -2721,6 +2721,11 @@
     
     // Assumes in correct section after the entry point.
     EmitLabel("func_begin", ++SubprogramCount);
+
+    // Emit label for the implicitly defined dbg.stoppoint at the start of
+    // the function.
+    const SourceLineInfo &LineInfo = MMI->getSourceLines()[0];
+    Asm->printLabel(LineInfo.getLabelID());
   }
   
   /// EndFunction - Gather and emit post-function debug information.

Modified: llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp?rev=46635&r1=46634&r2=46635&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp (original)
+++ llvm/trunk/lib/CodeGen/PrologEpilogInserter.cpp Fri Feb  1 03:10:45 2008
@@ -249,13 +249,6 @@
   MachineBasicBlock *MBB = Fn.begin();
   MachineBasicBlock::iterator I = MBB->begin();
 
-  // Do not insert prologue code before debug LABELs at the start of the
-  // entry block.
-  MachineModuleInfo *MMI = FFI->getMachineModuleInfo();
-  if (MMI && MMI->hasDebugInfo())
-    while (I != MBB->end() && I->isDebugLabel())
-      ++I;
-
   if (!TII.spillCalleeSavedRegisters(*MBB, I, CSI)) {
     for (unsigned i = 0, e = CSI.size(); i != e; ++i) {
       // Add the callee-saved register as live-in. It's killed at the spill.

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp?rev=46635&r1=46634&r2=46635&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/ScheduleDAG.cpp Fri Feb  1 03:10:45 2008
@@ -711,28 +711,7 @@
       }
     }
 
-    // Now that we have emitted all operands, emit this instruction itself.
-    if (ISD::isDebugLabel(Node) &&
-        !BB->empty() && &MF->front() == BB) {
-      // If we are inserting a debug label and this happens to be the first
-      // debug label in the entry block, it is the "function start" label.
-      // Make sure there are no other instructions before it.
-      unsigned NumLabels = 0;
-      MachineBasicBlock::iterator MBBI = BB->begin();
-      while (MBBI != BB->end()) {
-        // FIXME: This is a nasty short term workaround. For now, we are
-        // assuming there are two debug labels at the beginning of the
-        // entry block: one for dbg_func_start, one for the first
-        // dbg_stoppoint before actual code.
-        if (!MBBI->isDebugLabel() || ++NumLabels > 1)
-          break;
-        ++MBBI;
-      }
-      if (NumLabels <= 1)
-        BB->insert(BB->begin(), MI);
-      else
-        BB->push_back(MI);
-    } else if (II.usesCustomDAGSchedInsertionHook())
+    if (II.usesCustomDAGSchedInsertionHook())
       // Insert this instruction into the basic block using a target
       // specific inserter which may returns a new basic block.
       BB = DAG.getTargetLoweringInfo().EmitInstrWithCustomInserter(MI, BB);

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp?rev=46635&r1=46634&r2=46635&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp Fri Feb  1 03:10:45 2008
@@ -2641,13 +2641,21 @@
   }
   case Intrinsic::dbg_func_start: {
     MachineModuleInfo *MMI = DAG.getMachineModuleInfo();
+    if (!MMI) return 0;
     DbgFuncStartInst &FSI = cast<DbgFuncStartInst>(I);
-    if (MMI && FSI.getSubprogram() &&
-        MMI->Verify(FSI.getSubprogram())) {
-      unsigned LabelID = MMI->RecordRegionStart(FSI.getSubprogram());
-      DAG.setRoot(DAG.getNode(ISD::LABEL, MVT::Other, getRoot(),
-                              DAG.getConstant(LabelID, MVT::i32),
-                              DAG.getConstant(0, MVT::i32)));
+    Value *SP = FSI.getSubprogram();
+    if (SP && MMI->Verify(SP)) {
+      // llvm.dbg.func.start implicitly defines a dbg_stoppoint which is
+      // what (most?) gdb expects.
+      DebugInfoDesc *DD = MMI->getDescFor(SP);
+      assert(DD && "Not a debug information descriptor");
+      SubprogramDesc *Subprogram = cast<SubprogramDesc>(DD);
+      const CompileUnitDesc *CompileUnit = Subprogram->getFile();
+      unsigned SrcFile = MMI->RecordSource(CompileUnit->getDirectory(),
+                                           CompileUnit->getFileName());
+      // Record the source line but does create a label. It will be emitted
+      // at asm emission time.
+      MMI->RecordSourceLine(Subprogram->getLine(), 0, SrcFile);
     }
 
     return 0;

Modified: llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp?rev=46635&r1=46634&r2=46635&view=diff

==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCRegisterInfo.cpp Fri Feb  1 03:10:45 2008
@@ -712,16 +712,6 @@
   // Prepare for frame info.
   unsigned FrameLabelId = 0;
   
-  // Skip over the debug labels which mark the beginning of the function.
-  if (MMI && MMI->needsFrameInfo()) {
-    unsigned NumLabels = 0;
-    while (NumLabels <= 1 &&
-           MBBI != MBB.end() && MBBI->isDebugLabel()) {
-      ++NumLabels;
-      ++MBBI;
-    }
-  }
-
   // Scan the prolog, looking for an UPDATE_VRSAVE instruction.  If we find it,
   // process it.
   for (unsigned i = 0; MBBI != MBB.end(); ++i, ++MBBI) {

Modified: llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp?rev=46635&r1=46634&r2=46635&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86RegisterInfo.cpp Fri Feb  1 03:10:45 2008
@@ -525,16 +525,6 @@
           X86FI->getCalleeSavedFrameSize() +(-TailCallReturnAddrDelta));
   uint64_t NumBytes = StackSize - X86FI->getCalleeSavedFrameSize();
 
-  // Skip over the debug labels which mark the beginning of the function.
-  if (MMI && MMI->needsFrameInfo()) {
-    unsigned NumLabels = 0;
-    while (NumLabels <= 1 &&
-           MBBI != MBB.end() && MBBI->isDebugLabel()) {
-      ++NumLabels;
-      ++MBBI;
-    }
-  }
-
   // Insert stack pointer adjustment for later moving of return addr.  Only
   // applies to tail call optimized functions where the callee argument stack
   // size is bigger than the callers.





More information about the llvm-commits mailing list