25
25
#include " llvm/Support/CommandLine.h"
26
26
#include " llvm/Support/DataTypes.h"
27
27
#include " llvm/Support/Mangler.h"
28
+ #include " llvm/Support/Timer.h"
28
29
#include " llvm/Support/raw_ostream.h"
29
30
#include " llvm/System/Path.h"
30
31
#include " llvm/Target/TargetAsmInfo.h"
@@ -47,6 +48,16 @@ static RegisterPass<DwarfWriter>
47
48
X (" dwarfwriter" , " DWARF Information Writer" );
48
49
char DwarfWriter::ID = 0 ;
49
50
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
+
50
61
namespace llvm {
51
62
52
63
// ===----------------------------------------------------------------------===//
@@ -4365,12 +4376,17 @@ void DIE::dump() {
4365
4376
// / DwarfWriter Implementation
4366
4377
// /
4367
4378
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 ());
4369
4383
}
4370
4384
4371
4385
DwarfWriter::~DwarfWriter () {
4372
4386
delete DE;
4373
4387
delete DD;
4388
+ delete DwarfTimer;
4389
+ delete DwarfTimerGroup; DwarfTimerGroup = 0 ;
4374
4390
}
4375
4391
4376
4392
// / BeginModule - Emit all Dwarf sections that should come prior to the
@@ -4379,50 +4395,90 @@ void DwarfWriter::BeginModule(Module *M,
4379
4395
MachineModuleInfo *MMI,
4380
4396
raw_ostream &OS, AsmPrinter *A,
4381
4397
const TargetAsmInfo *T) {
4398
+ if (TimePassesIsEnabled)
4399
+ DwarfTimer->startTimer ();
4400
+
4382
4401
DE = new DwarfException (OS, A, T);
4383
4402
DD = new DwarfDebug (OS, A, T);
4384
4403
DE->BeginModule (M);
4385
4404
DD->BeginModule (M);
4386
4405
DD->SetDebugInfo (MMI);
4387
4406
DE->SetModuleInfo (MMI);
4407
+
4408
+ if (TimePassesIsEnabled)
4409
+ DwarfTimer->stopTimer ();
4388
4410
}
4389
4411
4390
4412
// / EndModule - Emit all Dwarf sections that should come after the content.
4391
4413
// /
4392
4414
void DwarfWriter::EndModule () {
4415
+ if (TimePassesIsEnabled)
4416
+ DwarfTimer->startTimer ();
4417
+
4393
4418
DE->EndModule ();
4394
4419
DD->EndModule ();
4420
+
4421
+ if (TimePassesIsEnabled)
4422
+ DwarfTimer->stopTimer ();
4395
4423
}
4396
4424
4397
4425
// / BeginFunction - Gather pre-function debug information. Assumes being
4398
4426
// / emitted immediately after the function entry point.
4399
4427
void DwarfWriter::BeginFunction (MachineFunction *MF) {
4428
+ if (TimePassesIsEnabled)
4429
+ DwarfTimer->startTimer ();
4430
+
4400
4431
DE->BeginFunction (MF);
4401
4432
DD->BeginFunction (MF);
4433
+
4434
+ if (TimePassesIsEnabled)
4435
+ DwarfTimer->stopTimer ();
4402
4436
}
4403
4437
4404
4438
// / EndFunction - Gather and emit post-function debug information.
4405
4439
// /
4406
4440
void DwarfWriter::EndFunction (MachineFunction *MF) {
4441
+ if (TimePassesIsEnabled)
4442
+ DwarfTimer->startTimer ();
4443
+
4407
4444
DD->EndFunction (MF);
4408
4445
DE->EndFunction ();
4409
4446
4410
4447
if (MachineModuleInfo *MMI = DD->getMMI () ? DD->getMMI () : DE->getMMI ())
4411
4448
// Clear function debug information.
4412
4449
MMI->EndFunction ();
4450
+
4451
+ if (TimePassesIsEnabled)
4452
+ DwarfTimer->stopTimer ();
4413
4453
}
4414
4454
4415
4455
// / ValidDebugInfo - Return true if V represents valid debug info value.
4416
4456
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;
4418
4466
}
4419
4467
4420
4468
// / RecordSourceLine - Records location information and associates it with a
4421
4469
// / label. Returns a unique label ID used to generate a label and provide
4422
4470
// / correspondence to the source line list.
4423
4471
unsigned DwarfWriter::RecordSourceLine (unsigned Line, unsigned Col,
4424
4472
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;
4426
4482
}
4427
4483
4428
4484
// / getOrCreateSourceID - Look up the source id with the given directory and
@@ -4431,32 +4487,78 @@ unsigned DwarfWriter::RecordSourceLine(unsigned Line, unsigned Col,
4431
4487
// / as well.
4432
4488
unsigned DwarfWriter::getOrCreateSourceID (const std::string &DirName,
4433
4489
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;
4435
4499
}
4436
4500
4437
4501
// / RecordRegionStart - Indicate the start of a region.
4438
4502
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;
4440
4512
}
4441
4513
4442
4514
// / RecordRegionEnd - Indicate the end of a region.
4443
4515
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;
4445
4525
}
4446
4526
4447
4527
// / getRecordSourceLineCount - Count source lines.
4448
4528
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;
4450
4538
}
4451
4539
4452
4540
// / RecordVariable - Indicate the declaration of a local variable.
4453
4541
// /
4454
4542
void DwarfWriter::RecordVariable (GlobalVariable *GV, unsigned FrameIndex) {
4543
+ if (TimePassesIsEnabled)
4544
+ DwarfTimer->startTimer ();
4545
+
4455
4546
DD->RecordVariable (GV, FrameIndex);
4547
+
4548
+ if (TimePassesIsEnabled)
4549
+ DwarfTimer->stopTimer ();
4456
4550
}
4457
4551
4458
4552
// / ShouldEmitDwarfDebug - Returns true if Dwarf debugging declarations should
4459
4553
// / be emitted.
4460
4554
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;
4462
4564
}
0 commit comments