[llvm-commits] [llvm] r66571 - in /llvm/trunk: include/llvm/CodeGen/DwarfWriter.h lib/CodeGen/AsmPrinter/DwarfWriter.cpp
Bill Wendling
isanbard at gmail.com
Tue Mar 10 13:41:53 PDT 2009
Author: void
Date: Tue Mar 10 15:41:52 2009
New Revision: 66571
URL: http://llvm.org/viewvc/llvm-project?rev=66571&view=rev
Log:
Add a timer to the DwarfWriter pass that measures the total time it takes to
emit exception and debug Dwarf info.
Modified:
llvm/trunk/include/llvm/CodeGen/DwarfWriter.h
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
Modified: llvm/trunk/include/llvm/CodeGen/DwarfWriter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/DwarfWriter.h?rev=66571&r1=66570&r2=66571&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/DwarfWriter.h (original)
+++ llvm/trunk/include/llvm/CodeGen/DwarfWriter.h Tue Mar 10 15:41:52 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/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp?rev=66571&r1=66570&r2=66571&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfWriter.cpp Tue Mar 10 15:41:52 2009
@@ -25,6 +25,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"
@@ -47,6 +48,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 {
//===----------------------------------------------------------------------===//
@@ -4365,12 +4376,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
@@ -4379,42 +4395,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
@@ -4422,7 +4470,15 @@
/// 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;
}
/// getOrCreateSourceID - Look up the source id with the given directory and
@@ -4431,32 +4487,78 @@
/// as well.
unsigned DwarfWriter::getOrCreateSourceID(const std::string &DirName,
const std::string &FileName) {
- return DD->getOrCreateSourceID(DirName, FileName);
+ if (TimePassesIsEnabled)
+ DwarfTimer->startTimer();
+
+ unsigned Res = DD->getOrCreateSourceID(DirName, FileName);
+
+ 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