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

Bill Wendling isanbard at gmail.com
Tue Mar 10 13:44:55 PDT 2009


Author: void
Date: Tue Mar 10 15:44:53 2009
New Revision: 66573

URL: http://llvm.org/viewvc/llvm-project?rev=66573&view=rev
Log:
Merge r66571 into Dib:

Add a timer to the DwarfWriter pass that measures the total time it takes to
emit exception and debug Dwarf info.

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=66573&r1=66572&r2=66573&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/include/llvm/CodeGen/DwarfWriter.h (original)
+++ llvm/branches/Apple/Dib/include/llvm/CodeGen/DwarfWriter.h Tue Mar 10 15:44:53 2009
@@ -33,6 +33,7 @@
 class Module;
 class GlobalVariable;
 class TargetAsmInfo;
+class Timer;
 class raw_ostream;
 
 //===----------------------------------------------------------------------===//
@@ -49,12 +50,15 @@
   ///
   DwarfException *DE;
 
+  /// DwarfTimer - Timer for the Dwarf writer.
+  /// 
+  Timer *DwarfTimer;
 public:
   static char ID; // Pass identification, replacement for typeid
 
   DwarfWriter();
   virtual ~DwarfWriter();
-  
+
   //===--------------------------------------------------------------------===//
   // Main entry points.
   //

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=66573&r1=66572&r2=66573&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/lib/CodeGen/AsmPrinter/DwarfWriter.cpp (original)
+++ llvm/branches/Apple/Dib/lib/CodeGen/AsmPrinter/DwarfWriter.cpp Tue Mar 10 15:44:53 2009
@@ -30,6 +30,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/DataTypes.h"
 #include "llvm/Support/Mangler.h"
+#include "llvm/Support/Timer.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/System/Path.h"
 #include "llvm/Target/TargetAsmInfo.h"
@@ -48,6 +49,16 @@
 X("dwarfwriter", "DWARF Information Writer");
 char DwarfWriter::ID = 0;
 
+namespace {
+
+static TimerGroup *DwarfTimerGroup = 0;
+static TimerGroup *getDwarfTimerGroup() {
+  if (DwarfTimerGroup) return DwarfTimerGroup;
+  return DwarfTimerGroup = new TimerGroup("Dwarf Exception and Debugging");
+}
+
+} // end anonymous namespace
+
 namespace llvm {
 
 //===----------------------------------------------------------------------===//
@@ -4281,12 +4292,17 @@
 /// DwarfWriter Implementation
 ///
 
-DwarfWriter::DwarfWriter() : ImmutablePass(&ID), DD(NULL), DE(NULL) {
+DwarfWriter::DwarfWriter()
+  : ImmutablePass(&ID), DD(0), DE(0), DwarfTimer(0) {
+  if (TimePassesIsEnabled) 
+    DwarfTimer = new Timer("Dwarf Writer", *getDwarfTimerGroup());
 }
 
 DwarfWriter::~DwarfWriter() {
   delete DE;
   delete DD;
+  delete DwarfTimer;
+  delete DwarfTimerGroup; DwarfTimerGroup = 0;
 }
 
 /// BeginModule - Emit all Dwarf sections that should come prior to the
@@ -4295,42 +4311,74 @@
                               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) {
-  return DD && DD->ValidDebugInfo(V);
+  if (TimePassesIsEnabled)
+    DwarfTimer->startTimer();
+
+  bool Res = DD && DD->ValidDebugInfo(V);
+
+  if (TimePassesIsEnabled)
+    DwarfTimer->stopTimer();
+
+  return Res;
 }
 
 /// RecordSourceLine - Records location information and associates it with a 
@@ -4338,39 +4386,93 @@
 /// correspondence to the source line list.
 unsigned DwarfWriter::RecordSourceLine(unsigned Line, unsigned Col, 
                                        unsigned Src) {
-  return DD->RecordSourceLine(Line, Col, Src);
+  if (TimePassesIsEnabled)
+    DwarfTimer->startTimer();
+
+  unsigned Res = DD->RecordSourceLine(Line, Col, Src);
+
+  if (TimePassesIsEnabled)
+    DwarfTimer->stopTimer();
+
+  return Res;
 }
 
 /// RecordSource - Register a source file with debug info. Returns an source
 /// ID.
 unsigned DwarfWriter::RecordSource(const std::string &Dir, 
                                    const std::string &File) {
-  return DD->RecordSource(Dir, File);
+  if (TimePassesIsEnabled)
+    DwarfTimer->startTimer();
+
+  unsigned Res = DD->RecordSource(Dir, File);
+
+  if (TimePassesIsEnabled)
+    DwarfTimer->stopTimer();
+
+  return Res;
 }
 
 /// RecordRegionStart - Indicate the start of a region.
 unsigned DwarfWriter::RecordRegionStart(GlobalVariable *V) {
-  return DD->RecordRegionStart(V);
+  if (TimePassesIsEnabled)
+    DwarfTimer->startTimer();
+
+  unsigned Res = DD->RecordRegionStart(V);
+
+  if (TimePassesIsEnabled)
+    DwarfTimer->stopTimer();
+
+  return Res;
 }
 
 /// RecordRegionEnd - Indicate the end of a region.
 unsigned DwarfWriter::RecordRegionEnd(GlobalVariable *V) {
-  return DD->RecordRegionEnd(V);
+  if (TimePassesIsEnabled)
+    DwarfTimer->startTimer();
+
+  unsigned Res = DD->RecordRegionEnd(V);
+
+  if (TimePassesIsEnabled)
+    DwarfTimer->stopTimer();
+
+  return Res;
 }
 
 /// getRecordSourceLineCount - Count source lines.
 unsigned DwarfWriter::getRecordSourceLineCount() {
-  return DD->getRecordSourceLineCount();
+  if (TimePassesIsEnabled)
+    DwarfTimer->startTimer();
+
+  unsigned Res = DD->getRecordSourceLineCount();
+
+  if (TimePassesIsEnabled)
+    DwarfTimer->stopTimer();
+
+  return Res;
 }
 
 /// 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 {
-  return DD->ShouldEmitDwarfDebug();
+  if (TimePassesIsEnabled)
+    DwarfTimer->startTimer();
+
+  bool Res = DD->ShouldEmitDwarfDebug();
+
+  if (TimePassesIsEnabled)
+    DwarfTimer->stopTimer();
+
+  return Res;
 }





More information about the llvm-commits mailing list