Skip to content

Commit e8dd284

Browse files
committed
Add a timer to the DwarfWriter pass that measures the total time it takes to
emit exception and debug Dwarf info. llvm-svn: 66571
1 parent e2c9def commit e8dd284

File tree

2 files changed

+115
-9
lines changed

2 files changed

+115
-9
lines changed

llvm/include/llvm/CodeGen/DwarfWriter.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class Value;
3333
class Module;
3434
class GlobalVariable;
3535
class TargetAsmInfo;
36+
class Timer;
3637
class raw_ostream;
3738

3839
//===----------------------------------------------------------------------===//
@@ -49,12 +50,15 @@ class DwarfWriter : public ImmutablePass {
4950
///
5051
DwarfException *DE;
5152

53+
/// DwarfTimer - Timer for the Dwarf writer.
54+
///
55+
Timer *DwarfTimer;
5256
public:
5357
static char ID; // Pass identification, replacement for typeid
5458

5559
DwarfWriter();
5660
virtual ~DwarfWriter();
57-
61+
5862
//===--------------------------------------------------------------------===//
5963
// Main entry points.
6064
//

llvm/lib/CodeGen/AsmPrinter/DwarfWriter.cpp

Lines changed: 110 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#include "llvm/Support/CommandLine.h"
2626
#include "llvm/Support/DataTypes.h"
2727
#include "llvm/Support/Mangler.h"
28+
#include "llvm/Support/Timer.h"
2829
#include "llvm/Support/raw_ostream.h"
2930
#include "llvm/System/Path.h"
3031
#include "llvm/Target/TargetAsmInfo.h"
@@ -47,6 +48,16 @@ static RegisterPass<DwarfWriter>
4748
X("dwarfwriter", "DWARF Information Writer");
4849
char DwarfWriter::ID = 0;
4950

51+
namespace {
52+
53+
static TimerGroup *DwarfTimerGroup = 0;
54+
static TimerGroup *getDwarfTimerGroup() {
55+
if (DwarfTimerGroup) return DwarfTimerGroup;
56+
return DwarfTimerGroup = new TimerGroup("Dwarf Exception and Debugging");
57+
}
58+
59+
} // end anonymous namespace
60+
5061
namespace llvm {
5162

5263
//===----------------------------------------------------------------------===//
@@ -4365,12 +4376,17 @@ void DIE::dump() {
43654376
/// DwarfWriter Implementation
43664377
///
43674378

4368-
DwarfWriter::DwarfWriter() : ImmutablePass(&ID), DD(NULL), DE(NULL) {
4379+
DwarfWriter::DwarfWriter()
4380+
: ImmutablePass(&ID), DD(0), DE(0), DwarfTimer(0) {
4381+
if (TimePassesIsEnabled)
4382+
DwarfTimer = new Timer("Dwarf Writer", *getDwarfTimerGroup());
43694383
}
43704384

43714385
DwarfWriter::~DwarfWriter() {
43724386
delete DE;
43734387
delete DD;
4388+
delete DwarfTimer;
4389+
delete DwarfTimerGroup; DwarfTimerGroup = 0;
43744390
}
43754391

43764392
/// BeginModule - Emit all Dwarf sections that should come prior to the
@@ -4379,50 +4395,90 @@ void DwarfWriter::BeginModule(Module *M,
43794395
MachineModuleInfo *MMI,
43804396
raw_ostream &OS, AsmPrinter *A,
43814397
const TargetAsmInfo *T) {
4398+
if (TimePassesIsEnabled)
4399+
DwarfTimer->startTimer();
4400+
43824401
DE = new DwarfException(OS, A, T);
43834402
DD = new DwarfDebug(OS, A, T);
43844403
DE->BeginModule(M);
43854404
DD->BeginModule(M);
43864405
DD->SetDebugInfo(MMI);
43874406
DE->SetModuleInfo(MMI);
4407+
4408+
if (TimePassesIsEnabled)
4409+
DwarfTimer->stopTimer();
43884410
}
43894411

43904412
/// EndModule - Emit all Dwarf sections that should come after the content.
43914413
///
43924414
void DwarfWriter::EndModule() {
4415+
if (TimePassesIsEnabled)
4416+
DwarfTimer->startTimer();
4417+
43934418
DE->EndModule();
43944419
DD->EndModule();
4420+
4421+
if (TimePassesIsEnabled)
4422+
DwarfTimer->stopTimer();
43954423
}
43964424

43974425
/// BeginFunction - Gather pre-function debug information. Assumes being
43984426
/// emitted immediately after the function entry point.
43994427
void DwarfWriter::BeginFunction(MachineFunction *MF) {
4428+
if (TimePassesIsEnabled)
4429+
DwarfTimer->startTimer();
4430+
44004431
DE->BeginFunction(MF);
44014432
DD->BeginFunction(MF);
4433+
4434+
if (TimePassesIsEnabled)
4435+
DwarfTimer->stopTimer();
44024436
}
44034437

44044438
/// EndFunction - Gather and emit post-function debug information.
44054439
///
44064440
void DwarfWriter::EndFunction(MachineFunction *MF) {
4441+
if (TimePassesIsEnabled)
4442+
DwarfTimer->startTimer();
4443+
44074444
DD->EndFunction(MF);
44084445
DE->EndFunction();
44094446

44104447
if (MachineModuleInfo *MMI = DD->getMMI() ? DD->getMMI() : DE->getMMI())
44114448
// Clear function debug information.
44124449
MMI->EndFunction();
4450+
4451+
if (TimePassesIsEnabled)
4452+
DwarfTimer->stopTimer();
44134453
}
44144454

44154455
/// ValidDebugInfo - Return true if V represents valid debug info value.
44164456
bool DwarfWriter::ValidDebugInfo(Value *V) {
4417-
return DD && DD->ValidDebugInfo(V);
4457+
if (TimePassesIsEnabled)
4458+
DwarfTimer->startTimer();
4459+
4460+
bool Res = DD && DD->ValidDebugInfo(V);
4461+
4462+
if (TimePassesIsEnabled)
4463+
DwarfTimer->stopTimer();
4464+
4465+
return Res;
44184466
}
44194467

44204468
/// RecordSourceLine - Records location information and associates it with a
44214469
/// label. Returns a unique label ID used to generate a label and provide
44224470
/// correspondence to the source line list.
44234471
unsigned DwarfWriter::RecordSourceLine(unsigned Line, unsigned Col,
44244472
unsigned Src) {
4425-
return DD->RecordSourceLine(Line, Col, Src);
4473+
if (TimePassesIsEnabled)
4474+
DwarfTimer->startTimer();
4475+
4476+
unsigned Res = DD->RecordSourceLine(Line, Col, Src);
4477+
4478+
if (TimePassesIsEnabled)
4479+
DwarfTimer->stopTimer();
4480+
4481+
return Res;
44264482
}
44274483

44284484
/// getOrCreateSourceID - Look up the source id with the given directory and
@@ -4431,32 +4487,78 @@ unsigned DwarfWriter::RecordSourceLine(unsigned Line, unsigned Col,
44314487
/// as well.
44324488
unsigned DwarfWriter::getOrCreateSourceID(const std::string &DirName,
44334489
const std::string &FileName) {
4434-
return DD->getOrCreateSourceID(DirName, FileName);
4490+
if (TimePassesIsEnabled)
4491+
DwarfTimer->startTimer();
4492+
4493+
unsigned Res = DD->getOrCreateSourceID(DirName, FileName);
4494+
4495+
if (TimePassesIsEnabled)
4496+
DwarfTimer->stopTimer();
4497+
4498+
return Res;
44354499
}
44364500

44374501
/// RecordRegionStart - Indicate the start of a region.
44384502
unsigned DwarfWriter::RecordRegionStart(GlobalVariable *V) {
4439-
return DD->RecordRegionStart(V);
4503+
if (TimePassesIsEnabled)
4504+
DwarfTimer->startTimer();
4505+
4506+
unsigned Res = DD->RecordRegionStart(V);
4507+
4508+
if (TimePassesIsEnabled)
4509+
DwarfTimer->stopTimer();
4510+
4511+
return Res;
44404512
}
44414513

44424514
/// RecordRegionEnd - Indicate the end of a region.
44434515
unsigned DwarfWriter::RecordRegionEnd(GlobalVariable *V) {
4444-
return DD->RecordRegionEnd(V);
4516+
if (TimePassesIsEnabled)
4517+
DwarfTimer->startTimer();
4518+
4519+
unsigned Res = DD->RecordRegionEnd(V);
4520+
4521+
if (TimePassesIsEnabled)
4522+
DwarfTimer->stopTimer();
4523+
4524+
return Res;
44454525
}
44464526

44474527
/// getRecordSourceLineCount - Count source lines.
44484528
unsigned DwarfWriter::getRecordSourceLineCount() {
4449-
return DD->getRecordSourceLineCount();
4529+
if (TimePassesIsEnabled)
4530+
DwarfTimer->startTimer();
4531+
4532+
unsigned Res = DD->getRecordSourceLineCount();
4533+
4534+
if (TimePassesIsEnabled)
4535+
DwarfTimer->stopTimer();
4536+
4537+
return Res;
44504538
}
44514539

44524540
/// RecordVariable - Indicate the declaration of a local variable.
44534541
///
44544542
void DwarfWriter::RecordVariable(GlobalVariable *GV, unsigned FrameIndex) {
4543+
if (TimePassesIsEnabled)
4544+
DwarfTimer->startTimer();
4545+
44554546
DD->RecordVariable(GV, FrameIndex);
4547+
4548+
if (TimePassesIsEnabled)
4549+
DwarfTimer->stopTimer();
44564550
}
44574551

44584552
/// ShouldEmitDwarfDebug - Returns true if Dwarf debugging declarations should
44594553
/// be emitted.
44604554
bool DwarfWriter::ShouldEmitDwarfDebug() const {
4461-
return DD->ShouldEmitDwarfDebug();
4555+
if (TimePassesIsEnabled)
4556+
DwarfTimer->startTimer();
4557+
4558+
bool Res = DD->ShouldEmitDwarfDebug();
4559+
4560+
if (TimePassesIsEnabled)
4561+
DwarfTimer->stopTimer();
4562+
4563+
return Res;
44624564
}

0 commit comments

Comments
 (0)