[llvm-commits] [llvm] r66578 - in /llvm/branches/Apple/Dib: include/llvm/CodeGen/DwarfWriter.h lib/CodeGen/AsmPrinter/DwarfWriter.cpp

Bill Wendling isanbard at gmail.com
Tue Mar 10 14:27:32 PDT 2009


Author: void
Date: Tue Mar 10 16:27:32 2009
New Revision: 66578

URL: http://llvm.org/viewvc/llvm-project?rev=66578&view=rev
Log:
--- Merging (from foreign repository) r66577 into '.':
U    include/llvm/CodeGen/DwarfWriter.h
U    lib/CodeGen/AsmPrinter/DwarfWriter.cpp

Refine the Dwarf writer timers so that they measure exception writing and debug
writing individually.

Modified:
    llvm/branches/Apple/Dib/include/llvm/CodeGen/DwarfWriter.h
    llvm/branches/Apple/Dib/lib/CodeGen/AsmPrinter/DwarfWriter.cpp

Modified: llvm/branches/Apple/Dib/include/llvm/CodeGen/DwarfWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/include/llvm/CodeGen/DwarfWriter.h?rev=66578&r1=66577&r2=66578&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/include/llvm/CodeGen/DwarfWriter.h (original)
+++ llvm/branches/Apple/Dib/include/llvm/CodeGen/DwarfWriter.h Tue Mar 10 16:27:32 2009
@@ -33,7 +33,6 @@
 class Module;
 class GlobalVariable;
 class TargetAsmInfo;
-class Timer;
 class raw_ostream;
 
 //===----------------------------------------------------------------------===//
@@ -50,9 +49,6 @@
   ///
   DwarfException *DE;
 
-  /// DwarfTimer - Timer for the Dwarf writer.
-  /// 
-  Timer *DwarfTimer;
 public:
   static char ID; // Pass identification, replacement for typeid
 

Modified: llvm/branches/Apple/Dib/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/CodeGen/AsmPrinter/DwarfWriter.cpp?rev=66578&r1=66577&r2=66578&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/lib/CodeGen/AsmPrinter/DwarfWriter.cpp (original)
+++ llvm/branches/Apple/Dib/lib/CodeGen/AsmPrinter/DwarfWriter.cpp Tue Mar 10 16:27:32 2009
@@ -1328,8 +1328,11 @@
   //
   DbgScope *RootDbgScope;
   
-  // DbgScopeMap - Tracks the scopes in the current function.
+  /// DbgScopeMap - Tracks the scopes in the current function.
   DenseMap<GlobalVariable *, DbgScope *> DbgScopeMap;
+
+  /// DebugTimer - Timer for the Dwarf debug writer.
+  Timer *DebugTimer;
   
   struct FunctionDebugFrameInfo {
     unsigned Number;
@@ -1342,12 +1345,12 @@
   std::vector<FunctionDebugFrameInfo> DebugFrames;
 
 public:
-
   /// ShouldEmitDwarfDebug - Returns true if Dwarf debugging declarations should
   /// be emitted.
   ///
   bool ShouldEmitDwarfDebug() const { return shouldEmit; }
 
+private:
   /// AssignAbbrevNumber - Define a unique number for the abbreviation.
   ///
   void AssignAbbrevNumber(DIEAbbrev &Abbrev) {
@@ -1558,8 +1561,6 @@
     Die->AddValue(Attribute, Block->BestForm(), Value);
   }
 
-private:
-
   /// AddSourceLine - Add location information to specified debug information
   /// entry.
   void AddSourceLine(DIE *Die, const DIVariable *V) {
@@ -2943,33 +2944,37 @@
   // Main entry points.
   //
   DwarfDebug(raw_ostream &OS, AsmPrinter *A, const TargetAsmInfo *T)
-  : Dwarf(OS, A, T, "dbg")
-  , MainCU(NULL)
-  , AbbreviationsSet(InitAbbreviationsSetSize)
-  , Abbreviations()
-  , ValuesSet(InitValuesSetSize)
-  , Values()
-  , StringPool()
-  , SectionMap()
-  , SectionSourceLines()
-  , didInitial(false)
-  , shouldEmit(false)
-  , RootDbgScope(NULL)
-  {
+    : Dwarf(OS, A, T, "dbg"), MainCU(0),
+      AbbreviationsSet(InitAbbreviationsSetSize), Abbreviations(),
+      ValuesSet(InitValuesSetSize), Values(), StringPool(), SectionMap(),
+      SectionSourceLines(), didInitial(false), shouldEmit(false),
+      RootDbgScope(0), DebugTimer(0) {
+    if (TimePassesIsEnabled)
+      DebugTimer = new Timer("Dwarf Debug Writer",
+                             *getDwarfTimerGroup());
   }
   virtual ~DwarfDebug() {
     for (unsigned j = 0, M = Values.size(); j < M; ++j)
       delete Values[j];
+
+    delete DebugTimer;
   }
 
   /// SetDebugInfo - Create global DIEs and emit initial debug info sections.
   /// This is inovked by the target AsmPrinter.
   void SetDebugInfo(MachineModuleInfo *mmi) {
+    if (TimePassesIsEnabled)
+      DebugTimer->startTimer();
+
     // Create all the compile unit DIEs.
     ConstructCompileUnits();
       
-    if (DW_CUs.empty())
+    if (DW_CUs.empty()) {
+      if (TimePassesIsEnabled)
+        DebugTimer->startTimer();
+
       return;
+    }
 
     // Create DIEs for each of the externally visible global variables.
     bool globalDIEs = ConstructGlobalVariableDIEs();
@@ -2979,8 +2984,12 @@
 
     // If there is not any debug info available for any global variables
     // and any subprograms then there is not any debug info to emit.
-    if (!globalDIEs && !subprogramDIEs)
+    if (!globalDIEs && !subprogramDIEs) {
+      if (TimePassesIsEnabled)
+        DebugTimer->startTimer();
+
       return;
+    }
 
     MMI = mmi;
     shouldEmit = true;
@@ -3004,6 +3013,9 @@
 
     // Emit initial sections
     EmitInitial();
+
+    if (TimePassesIsEnabled)
+      DebugTimer->stopTimer();
   }
 
   /// BeginModule - Emit all Dwarf sections that should come prior to the
@@ -3015,7 +3027,11 @@
   /// EndModule - Emit all Dwarf sections that should come after the content.
   ///
   void EndModule() {
-    if (!ShouldEmitDwarfDebug()) return;
+    if (!ShouldEmitDwarfDebug())
+      return;
+
+    if (TimePassesIsEnabled)
+      DebugTimer->startTimer();
 
     // Standard sections final addresses.
     Asm->SwitchToSection(TAI->getTextSection());
@@ -3066,15 +3082,21 @@
 
     // Emit info into a debug macinfo section.
     EmitDebugMacInfo();
+
+    if (TimePassesIsEnabled)
+      DebugTimer->stopTimer();
   }
 
   /// BeginFunction - Gather pre-function debug information.  Assumes being
   /// emitted immediately after the function entry point.
   void BeginFunction(MachineFunction *MF) {
-    this->MF = MF;
-
     if (!ShouldEmitDwarfDebug()) return;
 
+    if (TimePassesIsEnabled)
+      DebugTimer->startTimer();
+
+    this->MF = MF;
+
     // Begin accumulating function debug information.
     MMI->BeginFunction(MF);
 
@@ -3087,6 +3109,9 @@
       const SrcLineInfo &LineInfo = Lines[0];
       Asm->printLabel(LineInfo.getLabelID());
     }
+
+    if (TimePassesIsEnabled)
+      DebugTimer->stopTimer();
   }
 
   /// EndFunction - Gather and emit post-function debug information.
@@ -3094,6 +3119,9 @@
   void EndFunction(MachineFunction *MF) {
     if (!ShouldEmitDwarfDebug()) return;
 
+    if (TimePassesIsEnabled)
+      DebugTimer->startTimer();
+
     // Define end label for subprogram.
     EmitLabel("func_end", SubprogramCount);
 
@@ -3131,10 +3159,12 @@
       DbgScopeMap.clear();
       RootDbgScope = NULL;
     }
+
     Lines.clear();
-  }
 
-public:
+    if (TimePassesIsEnabled)
+      DebugTimer->stopTimer();
+  }
 
   /// ValidDebugInfo - Return true if V represents valid debug info value.
   bool ValidDebugInfo(Value *V) {
@@ -3152,11 +3182,19 @@
         && GV->getLinkage() != GlobalValue::LinkOnceLinkage)
       return false;
 
+    if (TimePassesIsEnabled)
+      DebugTimer->startTimer();
+
     DIDescriptor DI(GV);
+
     // Check current version. Allow Version6 for now.
     unsigned Version = DI.getVersion();
-    if (Version != LLVMDebugVersion && Version != LLVMDebugVersion6)
+    if (Version != LLVMDebugVersion && Version != LLVMDebugVersion6) {
+      if (TimePassesIsEnabled)
+        DebugTimer->stopTimer();
+
       return false;
+    }
 
     unsigned Tag = DI.getTag();
     switch (Tag) {
@@ -3173,6 +3211,9 @@
       break;
     }
 
+    if (TimePassesIsEnabled)
+      DebugTimer->stopTimer();
+
     return true;
   }
 
@@ -3180,10 +3221,17 @@
   /// label. Returns a unique label ID used to generate a label and provide
   /// correspondence to the source line list.
   unsigned RecordSourceLine(Value *V, unsigned Line, unsigned Col) {
+    if (TimePassesIsEnabled)
+      DebugTimer->startTimer();
+
     CompileUnit *Unit = DW_CUs[V];
     assert(Unit && "Unable to find CompileUnit");
     unsigned ID = MMI->NextLabelID();
     Lines.push_back(SrcLineInfo(Line, Col, Unit->getID(), ID));
+
+    if (TimePassesIsEnabled)
+      DebugTimer->stopTimer();
+
     return ID;
   }
   
@@ -3191,8 +3239,15 @@
   /// label. Returns a unique label ID used to generate a label and provide
   /// correspondence to the source line list.
   unsigned RecordSourceLine(unsigned Line, unsigned Col, unsigned Src) {
+    if (TimePassesIsEnabled)
+      DebugTimer->startTimer();
+
     unsigned ID = MMI->NextLabelID();
     Lines.push_back(SrcLineInfo(Line, Col, Src, ID));
+
+    if (TimePassesIsEnabled)
+      DebugTimer->stopTimer();
+
     return ID;
   }
 
@@ -3211,26 +3266,44 @@
   /// RecordRegionStart - Indicate the start of a region.
   ///
   unsigned RecordRegionStart(GlobalVariable *V) {
+    if (TimePassesIsEnabled)
+      DebugTimer->startTimer();
+
     DbgScope *Scope = getOrCreateScope(V);
     unsigned ID = MMI->NextLabelID();
     if (!Scope->getStartLabelID()) Scope->setStartLabelID(ID);
+
+    if (TimePassesIsEnabled)
+      DebugTimer->stopTimer();
+
     return ID;
   }
 
   /// RecordRegionEnd - Indicate the end of a region.
   ///
   unsigned RecordRegionEnd(GlobalVariable *V) {
+    if (TimePassesIsEnabled)
+      DebugTimer->startTimer();
+
     DbgScope *Scope = getOrCreateScope(V);
     unsigned ID = MMI->NextLabelID();
     Scope->setEndLabelID(ID);
+
+    if (TimePassesIsEnabled)
+      DebugTimer->stopTimer();
+
     return ID;
   }
 
   /// RecordVariable - Indicate the declaration of  a local variable.
   ///
   void RecordVariable(GlobalVariable *GV, unsigned FrameIndex) {
+    if (TimePassesIsEnabled)
+      DebugTimer->startTimer();
+
     DIDescriptor Desc(GV);
     DbgScope *Scope = NULL;
+
     if (Desc.getTag() == DW_TAG_variable) {
       // GV is a global variable.
       DIGlobalVariable DG(GV);
@@ -3240,9 +3313,13 @@
       DIVariable DV(GV);
       Scope = getOrCreateScope(DV.getContext().getGV());
     }
+
     assert(Scope && "Unable to find variable' scope");
     DbgVariable *DV = new DbgVariable(DIVariable(GV), FrameIndex);
     Scope->AddVariable(DV);
+
+    if (TimePassesIsEnabled)
+      DebugTimer->stopTimer();
   }
 };
 
@@ -3285,6 +3362,9 @@
   /// should be emitted.
   bool shouldEmitMovesModule;
 
+  /// ExceptionTimer - Timer for the Dwarf exception writer.
+  Timer *ExceptionTimer;
+
   /// EmitCommonEHFrame - Emit the common eh unwind frame.
   ///
   void EmitCommonEHFrame(const Function *Personality, unsigned Index) {
@@ -3893,14 +3973,17 @@
   // Main entry points.
   //
   DwarfException(raw_ostream &OS, AsmPrinter *A, const TargetAsmInfo *T)
-  : Dwarf(OS, A, T, "eh")
-  , shouldEmitTable(false)
-  , shouldEmitMoves(false)
-  , shouldEmitTableModule(false)
-  , shouldEmitMovesModule(false)
-  {}
+  : Dwarf(OS, A, T, "eh"), shouldEmitTable(false), shouldEmitMoves(false),
+    shouldEmitTableModule(false), shouldEmitMovesModule(false),
+    ExceptionTimer(0) {
+    if (TimePassesIsEnabled) 
+      ExceptionTimer = new Timer("Dwarf Exception Writer",
+                                 *getDwarfTimerGroup());
+  }
 
-  virtual ~DwarfException() {}
+  virtual ~DwarfException() {
+    delete ExceptionTimer;
+  }
 
   /// SetModuleInfo - Set machine module information when it's known that pass
   /// manager has created it.  Set by the target AsmPrinter.
@@ -3917,6 +4000,9 @@
   /// EndModule - Emit all exception information that should come after the
   /// content.
   void EndModule() {
+    if (TimePassesIsEnabled)
+      ExceptionTimer->startTimer();
+
     if (shouldEmitMovesModule || shouldEmitTableModule) {
       const std::vector<Function *> Personalities = MMI->getPersonalities();
       for (unsigned i =0; i < Personalities.size(); ++i)
@@ -3926,17 +4012,24 @@
              E = EHFrames.end(); I != E; ++I)
         EmitEHFrame(*I);
     }
+
+    if (TimePassesIsEnabled)
+      ExceptionTimer->stopTimer();
   }
 
   /// BeginFunction - Gather pre-function exception information.  Assumes being
   /// emitted immediately after the function entry point.
   void BeginFunction(MachineFunction *MF) {
+    if (TimePassesIsEnabled)
+      ExceptionTimer->startTimer();
+
     this->MF = MF;
     shouldEmitTable = shouldEmitMoves = false;
-    if (MMI && TAI->doesSupportExceptionHandling()) {
 
+    if (MMI && TAI->doesSupportExceptionHandling()) {
       // Map all labels and get rid of any dead landing pads.
       MMI->TidyLandingPads();
+
       // If any landing pads survive, we need an EH table.
       if (MMI->getLandingPads().size())
         shouldEmitTable = true;
@@ -3949,13 +4042,20 @@
         // Assumes in correct section after the entry point.
         EmitLabel("eh_func_begin", ++SubprogramCount);
     }
+
     shouldEmitTableModule |= shouldEmitTable;
     shouldEmitMovesModule |= shouldEmitMoves;
+
+    if (TimePassesIsEnabled)
+      ExceptionTimer->stopTimer();
   }
 
   /// EndFunction - Gather and emit post-function exception information.
   ///
   void EndFunction() {
+    if (TimePassesIsEnabled) 
+      ExceptionTimer->startTimer();
+
     if (shouldEmitMoves || shouldEmitTable) {
       EmitLabel("eh_func_end", SubprogramCount);
       EmitExceptionTable();
@@ -3963,13 +4063,16 @@
       // Save EH frame information
       EHFrames.
         push_back(FunctionEHFrameInfo(getAsm()->getCurrentFunctionEHName(MF),
-                                    SubprogramCount,
-                                    MMI->getPersonalityIndex(),
-                                    MF->getFrameInfo()->hasCalls(),
-                                    !MMI->getLandingPads().empty(),
-                                    MMI->getFrameMoves(),
-                                    MF->getFunction()));
-      }
+                                      SubprogramCount,
+                                      MMI->getPersonalityIndex(),
+                                      MF->getFrameInfo()->hasCalls(),
+                                      !MMI->getLandingPads().empty(),
+                                      MMI->getFrameMoves(),
+                                      MF->getFunction()));
+    }
+
+    if (TimePassesIsEnabled) 
+      ExceptionTimer->stopTimer();
   }
 };
 
@@ -4293,15 +4396,11 @@
 ///
 
 DwarfWriter::DwarfWriter()
-  : ImmutablePass(&ID), DD(0), DE(0), DwarfTimer(0) {
-  if (TimePassesIsEnabled) 
-    DwarfTimer = new Timer("Dwarf Writer", *getDwarfTimerGroup());
-}
+  : ImmutablePass(&ID), DD(0), DE(0) {}
 
 DwarfWriter::~DwarfWriter() {
   delete DE;
   delete DD;
-  delete DwarfTimer;
   delete DwarfTimerGroup; DwarfTimerGroup = 0;
 }
 
@@ -4311,74 +4410,42 @@
                               MachineModuleInfo *MMI,
                               raw_ostream &OS, AsmPrinter *A,
                               const TargetAsmInfo *T) {
-  if (TimePassesIsEnabled)
-    DwarfTimer->startTimer();
-
   DE = new DwarfException(OS, A, T);
   DD = new DwarfDebug(OS, A, T);
   DE->BeginModule(M);
   DD->BeginModule(M);
   DD->SetDebugInfo(MMI);
   DE->SetModuleInfo(MMI);
-
-  if (TimePassesIsEnabled)
-    DwarfTimer->stopTimer();
 }
 
 /// EndModule - Emit all Dwarf sections that should come after the content.
 ///
 void DwarfWriter::EndModule() {
-  if (TimePassesIsEnabled)
-    DwarfTimer->startTimer();
-
   DE->EndModule();
   DD->EndModule();
-
-  if (TimePassesIsEnabled)
-    DwarfTimer->stopTimer();
 }
 
 /// BeginFunction - Gather pre-function debug information.  Assumes being
 /// emitted immediately after the function entry point.
 void DwarfWriter::BeginFunction(MachineFunction *MF) {
-  if (TimePassesIsEnabled)
-    DwarfTimer->startTimer();
-
   DE->BeginFunction(MF);
   DD->BeginFunction(MF);
-
-  if (TimePassesIsEnabled)
-    DwarfTimer->stopTimer();
 }
 
 /// EndFunction - Gather and emit post-function debug information.
 ///
 void DwarfWriter::EndFunction(MachineFunction *MF) {
-  if (TimePassesIsEnabled)
-    DwarfTimer->startTimer();
-
   DD->EndFunction(MF);
   DE->EndFunction();
 
   if (MachineModuleInfo *MMI = DD->getMMI() ? DD->getMMI() : DE->getMMI())
     // Clear function debug information.
     MMI->EndFunction();
-
-  if (TimePassesIsEnabled)
-    DwarfTimer->stopTimer();
 }
 
 /// ValidDebugInfo - Return true if V represents valid debug info value.
 bool DwarfWriter::ValidDebugInfo(Value *V) {
-  if (TimePassesIsEnabled)
-    DwarfTimer->startTimer();
-
-  bool Res = DD && DD->ValidDebugInfo(V);
-
-  if (TimePassesIsEnabled)
-    DwarfTimer->stopTimer();
-
-  return Res;
+  return DD && DD->ValidDebugInfo(V);
 }
 
 /// RecordSourceLine - Records location information and associates it with a 
@@ -4386,93 +4453,39 @@
 /// correspondence to the source line list.
 unsigned DwarfWriter::RecordSourceLine(unsigned Line, unsigned Col, 
                                        unsigned Src) {
-  if (TimePassesIsEnabled)
-    DwarfTimer->startTimer();
-
-  unsigned Res = DD->RecordSourceLine(Line, Col, Src);
-
-  if (TimePassesIsEnabled)
-    DwarfTimer->stopTimer();
-
-  return Res;
+  return DD->RecordSourceLine(Line, Col, Src);
 }
 
 /// RecordSource - Register a source file with debug info. Returns an source
 /// ID.
 unsigned DwarfWriter::RecordSource(const std::string &Dir, 
                                    const std::string &File) {
-  if (TimePassesIsEnabled)
-    DwarfTimer->startTimer();
-
-  unsigned Res = DD->RecordSource(Dir, File);
-
-  if (TimePassesIsEnabled)
-    DwarfTimer->stopTimer();
-
-  return Res;
+  return DD->RecordSource(Dir, File);
 }
 
 /// RecordRegionStart - Indicate the start of a region.
 unsigned DwarfWriter::RecordRegionStart(GlobalVariable *V) {
-  if (TimePassesIsEnabled)
-    DwarfTimer->startTimer();
-
-  unsigned Res = DD->RecordRegionStart(V);
-
-  if (TimePassesIsEnabled)
-    DwarfTimer->stopTimer();
-
-  return Res;
+  return DD->RecordRegionStart(V);
 }
 
 /// RecordRegionEnd - Indicate the end of a region.
 unsigned DwarfWriter::RecordRegionEnd(GlobalVariable *V) {
-  if (TimePassesIsEnabled)
-    DwarfTimer->startTimer();
-
-  unsigned Res = DD->RecordRegionEnd(V);
-
-  if (TimePassesIsEnabled)
-    DwarfTimer->stopTimer();
-
-  return Res;
+  return DD->RecordRegionEnd(V);
 }
 
 /// getRecordSourceLineCount - Count source lines.
 unsigned DwarfWriter::getRecordSourceLineCount() {
-  if (TimePassesIsEnabled)
-    DwarfTimer->startTimer();
-
-  unsigned Res = DD->getRecordSourceLineCount();
-
-  if (TimePassesIsEnabled)
-    DwarfTimer->stopTimer();
-
-  return Res;
+  return DD->getRecordSourceLineCount();
 }
 
 /// RecordVariable - Indicate the declaration of  a local variable.
 ///
 void DwarfWriter::RecordVariable(GlobalVariable *GV, unsigned FrameIndex) {
-  if (TimePassesIsEnabled)
-    DwarfTimer->startTimer();
-
   DD->RecordVariable(GV, FrameIndex);
-
-  if (TimePassesIsEnabled)
-    DwarfTimer->stopTimer();
 }
 
 /// ShouldEmitDwarfDebug - Returns true if Dwarf debugging declarations should
 /// be emitted.
 bool DwarfWriter::ShouldEmitDwarfDebug() const {
-  if (TimePassesIsEnabled)
-    DwarfTimer->startTimer();
-
-  bool Res = DD->ShouldEmitDwarfDebug();
-
-  if (TimePassesIsEnabled)
-    DwarfTimer->stopTimer();
-
-  return Res;
+  return DD->ShouldEmitDwarfDebug();
 }





More information about the llvm-commits mailing list