aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2009-03-10 20:41:52 +0000
committerBill Wendling <isanbard@gmail.com>2009-03-10 20:41:52 +0000
commit91b8b8010a55ca2969f379e6a110420afbbac12e (patch)
tree64a42cc1d45cb35ba946cf246583d49b606f241d
parent111def86f75da0cdc8808a5be92359a264d53da6 (diff)
downloadexternal_llvm-91b8b8010a55ca2969f379e6a110420afbbac12e.zip
external_llvm-91b8b8010a55ca2969f379e6a110420afbbac12e.tar.gz
external_llvm-91b8b8010a55ca2969f379e6a110420afbbac12e.tar.bz2
Add a timer to the DwarfWriter pass that measures the total time it takes to
emit exception and debug Dwarf info. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66571 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/CodeGen/DwarfWriter.h6
-rw-r--r--lib/CodeGen/AsmPrinter/DwarfWriter.cpp118
2 files changed, 115 insertions, 9 deletions
diff --git a/include/llvm/CodeGen/DwarfWriter.h b/include/llvm/CodeGen/DwarfWriter.h
index a559732..97cf80b 100644
--- a/include/llvm/CodeGen/DwarfWriter.h
+++ b/include/llvm/CodeGen/DwarfWriter.h
@@ -33,6 +33,7 @@ class Value;
class Module;
class GlobalVariable;
class TargetAsmInfo;
+class Timer;
class raw_ostream;
//===----------------------------------------------------------------------===//
@@ -49,12 +50,15 @@ private:
///
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.
//
diff --git a/lib/CodeGen/AsmPrinter/DwarfWriter.cpp b/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
index c5b24ef..ec4f465 100644
--- a/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
+++ b/lib/CodeGen/AsmPrinter/DwarfWriter.cpp
@@ -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 @@ static RegisterPass<DwarfWriter>
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 @@ void DIE::dump() {
/// 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 @@ void DwarfWriter::BeginModule(Module *M,
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 @@ bool DwarfWriter::ValidDebugInfo(Value *V) {
/// 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 @@ unsigned DwarfWriter::RecordSourceLine(unsigned Line, unsigned Col,
/// 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;
}