Timer: Track name and description.

The previously used "names" are rather descriptions (they use multiple
words and contain spaces), use short programming language identifier
like strings for the "names" which should be used when exporting to
machine parseable formats.

Also removed a unused TimerGroup from Hexxagon.

Differential Revision: https://reviews.llvm.org/D25583

llvm-svn: 287369
This commit is contained in:
Matthias Braun 2016-11-18 19:43:18 +00:00
parent b51774ac8c
commit 9f15a79e5d
17 changed files with 169 additions and 100 deletions

View File

@ -53,6 +53,10 @@ Non-comprehensive list of changes in this release
* Minimum compiler version to build has been raised to GCC 4.8 and VS 2015. * Minimum compiler version to build has been raised to GCC 4.8 and VS 2015.
* The Timer related APIs now expect a Name and Description. When upgrading code
the previously used names should become descriptions and a short name in the
style of a programming language identifier should be added.
* ... next change ... * ... next change ...
.. NOTE .. NOTE

View File

@ -122,11 +122,16 @@ private:
struct HandlerInfo { struct HandlerInfo {
AsmPrinterHandler *Handler; AsmPrinterHandler *Handler;
const char *TimerName, *TimerGroupName; const char *TimerName;
const char *TimerDescription;
const char *TimerGroupName;
const char *TimerGroupDescription;
HandlerInfo(AsmPrinterHandler *Handler, const char *TimerName, HandlerInfo(AsmPrinterHandler *Handler, const char *TimerName,
const char *TimerGroupName) const char *TimerDescription, const char *TimerGroupName,
const char *TimerGroupDescription)
: Handler(Handler), TimerName(TimerName), : Handler(Handler), TimerName(TimerName),
TimerGroupName(TimerGroupName) {} TimerDescription(TimerDescription), TimerGroupName(TimerGroupName),
TimerGroupDescription(TimerGroupDescription) {}
}; };
/// A vector of all debug/EH info emitters we should use. This vector /// A vector of all debug/EH info emitters we should use. This vector
/// maintains ownership of the emitters. /// maintains ownership of the emitters.

View File

@ -77,6 +77,7 @@ class Timer {
TimeRecord Time; ///< The total time captured. TimeRecord Time; ///< The total time captured.
TimeRecord StartTime; ///< The time startTimer() was last called. TimeRecord StartTime; ///< The time startTimer() was last called.
std::string Name; ///< The name of this time variable. std::string Name; ///< The name of this time variable.
std::string Description; ///< Description of this time variable.
bool Running; ///< Is the timer currently running? bool Running; ///< Is the timer currently running?
bool Triggered; ///< Has the timer ever been triggered? bool Triggered; ///< Has the timer ever been triggered?
TimerGroup *TG = nullptr; ///< The TimerGroup this Timer is in. TimerGroup *TG = nullptr; ///< The TimerGroup this Timer is in.
@ -84,8 +85,12 @@ class Timer {
Timer **Prev; ///< Pointer to \p Next of previous timer in group. Timer **Prev; ///< Pointer to \p Next of previous timer in group.
Timer *Next; ///< Next timer in the group. Timer *Next; ///< Next timer in the group.
public: public:
explicit Timer(StringRef N) { init(N); } explicit Timer(StringRef Name, StringRef Description) {
Timer(StringRef N, TimerGroup &tg) { init(N, tg); } init(Name, Description);
}
Timer(StringRef Name, StringRef Description, TimerGroup &tg) {
init(Name, Description, tg);
}
Timer(const Timer &RHS) { Timer(const Timer &RHS) {
assert(!RHS.TG && "Can only copy uninitialized timers"); assert(!RHS.TG && "Can only copy uninitialized timers");
} }
@ -97,10 +102,11 @@ public:
/// Create an uninitialized timer, client must use 'init'. /// Create an uninitialized timer, client must use 'init'.
explicit Timer() {} explicit Timer() {}
void init(StringRef N); void init(StringRef Name, StringRef Description);
void init(StringRef N, TimerGroup &tg); void init(StringRef Name, StringRef Description, TimerGroup &tg);
const std::string &getName() const { return Name; } const std::string &getName() const { return Name; }
const std::string &getDescription() const { return Description; }
bool isInitialized() const { return TG != nullptr; } bool isInitialized() const { return TG != nullptr; }
/// Check if the timer is currently running. /// Check if the timer is currently running.
@ -152,8 +158,9 @@ public:
/// statement. All timers with the same name are merged. This is primarily /// statement. All timers with the same name are merged. This is primarily
/// used for debugging and for hunting performance problems. /// used for debugging and for hunting performance problems.
struct NamedRegionTimer : public TimeRegion { struct NamedRegionTimer : public TimeRegion {
explicit NamedRegionTimer(StringRef Name, StringRef GroupName, explicit NamedRegionTimer(StringRef Name, StringRef Description,
bool Enabled = true); StringRef GroupName,
StringRef GroupDescription, bool Enabled = true);
}; };
/// The TimerGroup class is used to group together related timers into a single /// The TimerGroup class is used to group together related timers into a single
@ -162,6 +169,7 @@ struct NamedRegionTimer : public TimeRegion {
/// TimerGroup can be specified for a newly created timer in its constructor. /// TimerGroup can be specified for a newly created timer in its constructor.
class TimerGroup { class TimerGroup {
std::string Name; std::string Name;
std::string Description;
Timer *FirstTimer = nullptr; ///< First timer in the group. Timer *FirstTimer = nullptr; ///< First timer in the group.
std::vector<std::pair<TimeRecord, std::string>> TimersToPrint; std::vector<std::pair<TimeRecord, std::string>> TimersToPrint;
@ -171,10 +179,13 @@ class TimerGroup {
void operator=(const TimerGroup &TG) = delete; void operator=(const TimerGroup &TG) = delete;
public: public:
explicit TimerGroup(StringRef name); explicit TimerGroup(StringRef Name, StringRef Description);
~TimerGroup(); ~TimerGroup();
void setName(StringRef name) { Name.assign(name.begin(), name.end()); } void setName(StringRef NewName, StringRef NewDescription) {
Name.assign(NewName.begin(), NewName.end());
Description.assign(NewDescription.begin(), NewDescription.end());
}
/// Print any started timers in this group and zero them. /// Print any started timers in this group and zero them.
void print(raw_ostream &OS); void print(raw_ostream &OS);

View File

@ -55,10 +55,15 @@ using namespace llvm;
#define DEBUG_TYPE "asm-printer" #define DEBUG_TYPE "asm-printer"
static const char *const DWARFGroupName = "DWARF Emission"; static const char *const DWARFGroupName = "dwarf";
static const char *const DbgTimerName = "Debug Info Emission"; static const char *const DWARFGroupDescription = "DWARF Emission";
static const char *const EHTimerName = "DWARF Exception Writer"; static const char *const DbgTimerName = "emit";
static const char *const CodeViewLineTablesGroupName = "CodeView Line Tables"; static const char *const DbgTimerDescription = "Debug Info Emission";
static const char *const EHTimerName = "write_exception";
static const char *const EHTimerDescription = "DWARF Exception Writer";
static const char *const CodeViewLineTablesGroupName = "linetables";
static const char *const CodeViewLineTablesGroupDescription =
"CodeView Line Tables";
STATISTIC(EmittedInsts, "Number of machine instrs printed"); STATISTIC(EmittedInsts, "Number of machine instrs printed");
@ -244,13 +249,15 @@ bool AsmPrinter::doInitialization(Module &M) {
bool EmitCodeView = MMI->getModule()->getCodeViewFlag(); bool EmitCodeView = MMI->getModule()->getCodeViewFlag();
if (EmitCodeView && TM.getTargetTriple().isKnownWindowsMSVCEnvironment()) { if (EmitCodeView && TM.getTargetTriple().isKnownWindowsMSVCEnvironment()) {
Handlers.push_back(HandlerInfo(new CodeViewDebug(this), Handlers.push_back(HandlerInfo(new CodeViewDebug(this),
DbgTimerName, DbgTimerName, DbgTimerDescription,
CodeViewLineTablesGroupName)); CodeViewLineTablesGroupName,
CodeViewLineTablesGroupDescription));
} }
if (!EmitCodeView || MMI->getModule()->getDwarfVersion()) { if (!EmitCodeView || MMI->getModule()->getDwarfVersion()) {
DD = new DwarfDebug(this, &M); DD = new DwarfDebug(this, &M);
DD->beginModule(); DD->beginModule();
Handlers.push_back(HandlerInfo(DD, DbgTimerName, DWARFGroupName)); Handlers.push_back(HandlerInfo(DD, DbgTimerName, DbgTimerDescription,
DWARFGroupName, DWARFGroupDescription));
} }
} }
@ -278,7 +285,8 @@ bool AsmPrinter::doInitialization(Module &M) {
break; break;
} }
if (ES) if (ES)
Handlers.push_back(HandlerInfo(ES, EHTimerName, DWARFGroupName)); Handlers.push_back(HandlerInfo(ES, EHTimerName, EHTimerDescription,
DWARFGroupName, DWARFGroupDescription));
return false; return false;
} }
@ -399,7 +407,9 @@ void AsmPrinter::EmitGlobalVariable(const GlobalVariable *GV) {
unsigned AlignLog = getGVAlignmentLog2(GV, DL); unsigned AlignLog = getGVAlignmentLog2(GV, DL);
for (const HandlerInfo &HI : Handlers) { for (const HandlerInfo &HI : Handlers) {
NamedRegionTimer T(HI.TimerName, HI.TimerGroupName, TimePassesIsEnabled); NamedRegionTimer T(HI.TimerName, HI.TimerDescription,
HI.TimerGroupName, HI.TimerGroupDescription,
TimePassesIsEnabled);
HI.Handler->setSymbolSize(GVSym, Size); HI.Handler->setSymbolSize(GVSym, Size);
} }
@ -588,7 +598,8 @@ void AsmPrinter::EmitFunctionHeader() {
// Emit pre-function debug and/or EH information. // Emit pre-function debug and/or EH information.
for (const HandlerInfo &HI : Handlers) { for (const HandlerInfo &HI : Handlers) {
NamedRegionTimer T(HI.TimerName, HI.TimerGroupName, TimePassesIsEnabled); NamedRegionTimer T(HI.TimerName, HI.TimerDescription, HI.TimerGroupName,
HI.TimerGroupDescription, TimePassesIsEnabled);
HI.Handler->beginFunction(MF); HI.Handler->beginFunction(MF);
} }
@ -852,7 +863,8 @@ void AsmPrinter::EmitFunctionBody() {
if (ShouldPrintDebugScopes) { if (ShouldPrintDebugScopes) {
for (const HandlerInfo &HI : Handlers) { for (const HandlerInfo &HI : Handlers) {
NamedRegionTimer T(HI.TimerName, HI.TimerGroupName, NamedRegionTimer T(HI.TimerName, HI.TimerDescription,
HI.TimerGroupName, HI.TimerGroupDescription,
TimePassesIsEnabled); TimePassesIsEnabled);
HI.Handler->beginInstruction(&MI); HI.Handler->beginInstruction(&MI);
} }
@ -896,7 +908,8 @@ void AsmPrinter::EmitFunctionBody() {
if (ShouldPrintDebugScopes) { if (ShouldPrintDebugScopes) {
for (const HandlerInfo &HI : Handlers) { for (const HandlerInfo &HI : Handlers) {
NamedRegionTimer T(HI.TimerName, HI.TimerGroupName, NamedRegionTimer T(HI.TimerName, HI.TimerDescription,
HI.TimerGroupName, HI.TimerGroupDescription,
TimePassesIsEnabled); TimePassesIsEnabled);
HI.Handler->endInstruction(); HI.Handler->endInstruction();
} }
@ -954,7 +967,8 @@ void AsmPrinter::EmitFunctionBody() {
} }
for (const HandlerInfo &HI : Handlers) { for (const HandlerInfo &HI : Handlers) {
NamedRegionTimer T(HI.TimerName, HI.TimerGroupName, TimePassesIsEnabled); NamedRegionTimer T(HI.TimerName, HI.TimerDescription, HI.TimerGroupName,
HI.TimerGroupDescription, TimePassesIsEnabled);
HI.Handler->markFunctionEnd(); HI.Handler->markFunctionEnd();
} }
@ -963,7 +977,8 @@ void AsmPrinter::EmitFunctionBody() {
// Emit post-function debug and/or EH information. // Emit post-function debug and/or EH information.
for (const HandlerInfo &HI : Handlers) { for (const HandlerInfo &HI : Handlers) {
NamedRegionTimer T(HI.TimerName, HI.TimerGroupName, TimePassesIsEnabled); NamedRegionTimer T(HI.TimerName, HI.TimerDescription, HI.TimerGroupName,
HI.TimerGroupDescription, TimePassesIsEnabled);
HI.Handler->endFunction(MF); HI.Handler->endFunction(MF);
} }
MMI->EndFunction(); MMI->EndFunction();
@ -1154,8 +1169,8 @@ bool AsmPrinter::doFinalization(Module &M) {
// Finalize debug and EH information. // Finalize debug and EH information.
for (const HandlerInfo &HI : Handlers) { for (const HandlerInfo &HI : Handlers) {
NamedRegionTimer T(HI.TimerName, HI.TimerGroupName, NamedRegionTimer T(HI.TimerName, HI.TimerDescription, HI.TimerGroupName,
TimePassesIsEnabled); HI.TimerGroupDescription, TimePassesIsEnabled);
HI.Handler->endModule(); HI.Handler->endModule();
delete HI.Handler; delete HI.Handler;
} }

View File

@ -120,8 +120,10 @@ static cl::opt<LinkageNameOption>
"Abstract subprograms")), "Abstract subprograms")),
cl::init(DefaultLinkageNames)); cl::init(DefaultLinkageNames));
static const char *const DWARFGroupName = "DWARF Emission"; static const char *const DWARFGroupName = "dwarf";
static const char *const DbgTimerName = "DWARF Debug Writer"; static const char *const DWARFGroupDescription = "DWARF Emission";
static const char *const DbgTimerName = "writer";
static const char *const DbgTimerDescription = "DWARF Debug Writer";
void DebugLocDwarfExpression::EmitOp(uint8_t Op, const char *Comment) { void DebugLocDwarfExpression::EmitOp(uint8_t Op, const char *Comment) {
BS.EmitInt8( BS.EmitInt8(
@ -464,7 +466,8 @@ void DwarfDebug::constructAndAddImportedEntityDIE(DwarfCompileUnit &TheCU,
// global DIEs and emit initial debug info sections. This is invoked by // global DIEs and emit initial debug info sections. This is invoked by
// the target AsmPrinter. // the target AsmPrinter.
void DwarfDebug::beginModule() { void DwarfDebug::beginModule() {
NamedRegionTimer T(DbgTimerName, DWARFGroupName, TimePassesIsEnabled); NamedRegionTimer T(DbgTimerName, DbgTimerDescription, DWARFGroupName,
DWARFGroupDescription, TimePassesIsEnabled);
if (DisableDebugInfoPrinting) if (DisableDebugInfoPrinting)
return; return;

View File

@ -41,7 +41,8 @@ static cl::opt<bool, true>
VerifyRegAlloc("verify-regalloc", cl::location(RegAllocBase::VerifyEnabled), VerifyRegAlloc("verify-regalloc", cl::location(RegAllocBase::VerifyEnabled),
cl::desc("Verify during register allocation")); cl::desc("Verify during register allocation"));
const char RegAllocBase::TimerGroupName[] = "Register Allocation"; const char RegAllocBase::TimerGroupName[] = "regalloc";
const char RegAllocBase::TimerGroupDescription[] = "Register Allocation";
bool RegAllocBase::VerifyEnabled = false; bool RegAllocBase::VerifyEnabled = false;
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -67,7 +68,8 @@ void RegAllocBase::init(VirtRegMap &vrm,
// register, unify them with the corresponding LiveIntervalUnion, otherwise push // register, unify them with the corresponding LiveIntervalUnion, otherwise push
// them on the priority queue for later assignment. // them on the priority queue for later assignment.
void RegAllocBase::seedLiveRegs() { void RegAllocBase::seedLiveRegs() {
NamedRegionTimer T("Seed Live Regs", TimerGroupName, TimePassesIsEnabled); NamedRegionTimer T("seed", "Seed Live Regs", TimerGroupName,
TimerGroupDescription, TimePassesIsEnabled);
for (unsigned i = 0, e = MRI->getNumVirtRegs(); i != e; ++i) { for (unsigned i = 0, e = MRI->getNumVirtRegs(); i != e; ++i) {
unsigned Reg = TargetRegisterInfo::index2VirtReg(i); unsigned Reg = TargetRegisterInfo::index2VirtReg(i);
if (MRI->reg_nodbg_empty(Reg)) if (MRI->reg_nodbg_empty(Reg))

View File

@ -105,6 +105,7 @@ protected:
// Use this group name for NamedRegionTimer. // Use this group name for NamedRegionTimer.
static const char TimerGroupName[]; static const char TimerGroupName[];
static const char TimerGroupDescription[];
/// Method called when the allocator is about to remove a LiveInterval. /// Method called when the allocator is about to remove a LiveInterval.
virtual void aboutToRemoveInterval(LiveInterval &LI) {} virtual void aboutToRemoveInterval(LiveInterval &LI) {}

View File

@ -869,7 +869,8 @@ unsigned RAGreedy::tryEvict(LiveInterval &VirtReg,
AllocationOrder &Order, AllocationOrder &Order,
SmallVectorImpl<unsigned> &NewVRegs, SmallVectorImpl<unsigned> &NewVRegs,
unsigned CostPerUseLimit) { unsigned CostPerUseLimit) {
NamedRegionTimer T("Evict", TimerGroupName, TimePassesIsEnabled); NamedRegionTimer T("evict", "Evict", TimerGroupName, TimerGroupDescription,
TimePassesIsEnabled);
// Keep track of the cheapest interference seen so far. // Keep track of the cheapest interference seen so far.
EvictionCost BestCost; EvictionCost BestCost;
@ -1967,7 +1968,8 @@ unsigned RAGreedy::trySplit(LiveInterval &VirtReg, AllocationOrder &Order,
// Local intervals are handled separately. // Local intervals are handled separately.
if (LIS->intervalIsInOneMBB(VirtReg)) { if (LIS->intervalIsInOneMBB(VirtReg)) {
NamedRegionTimer T("Local Splitting", TimerGroupName, TimePassesIsEnabled); NamedRegionTimer T("local_split", "Local Splitting", TimerGroupName,
TimerGroupDescription, TimePassesIsEnabled);
SA->analyze(&VirtReg); SA->analyze(&VirtReg);
unsigned PhysReg = tryLocalSplit(VirtReg, Order, NewVRegs); unsigned PhysReg = tryLocalSplit(VirtReg, Order, NewVRegs);
if (PhysReg || !NewVRegs.empty()) if (PhysReg || !NewVRegs.empty())
@ -1975,7 +1977,8 @@ unsigned RAGreedy::trySplit(LiveInterval &VirtReg, AllocationOrder &Order,
return tryInstructionSplit(VirtReg, Order, NewVRegs); return tryInstructionSplit(VirtReg, Order, NewVRegs);
} }
NamedRegionTimer T("Global Splitting", TimerGroupName, TimePassesIsEnabled); NamedRegionTimer T("global_split", "Global Splitting", TimerGroupName,
TimerGroupDescription, TimePassesIsEnabled);
SA->analyze(&VirtReg); SA->analyze(&VirtReg);
@ -2593,7 +2596,8 @@ unsigned RAGreedy::selectOrSplitImpl(LiveInterval &VirtReg,
DEBUG(dbgs() << "Do as if this register is in memory\n"); DEBUG(dbgs() << "Do as if this register is in memory\n");
NewVRegs.push_back(VirtReg.reg); NewVRegs.push_back(VirtReg.reg);
} else { } else {
NamedRegionTimer T("Spiller", TimerGroupName, TimePassesIsEnabled); NamedRegionTimer T("spill", "Spiller", TimerGroupName,
TimerGroupDescription, TimePassesIsEnabled);
LiveRangeEdit LRE(&VirtReg, NewVRegs, *MF, *LIS, VRM, this, &DeadRemats); LiveRangeEdit LRE(&VirtReg, NewVRegs, *MF, *LIS, VRM, this, &DeadRemats);
spiller().spill(LRE); spiller().spill(LRE);
setStage(NewVRegs.begin(), NewVRegs.end(), RS_Done); setStage(NewVRegs.begin(), NewVRegs.end(), RS_Done);

View File

@ -725,9 +725,8 @@ void SelectionDAGISel::ComputeLiveOutVRegInfo() {
} }
void SelectionDAGISel::CodeGenAndEmitDAG() { void SelectionDAGISel::CodeGenAndEmitDAG() {
std::string GroupName; StringRef GroupName = "sdag";
if (TimePassesIsEnabled) StringRef GroupDescription = "Instruction Selection and Scheduling";
GroupName = "Instruction Selection and Scheduling";
std::string BlockName; std::string BlockName;
int BlockNumber = -1; int BlockNumber = -1;
(void)BlockNumber; (void)BlockNumber;
@ -755,7 +754,8 @@ void SelectionDAGISel::CodeGenAndEmitDAG() {
// Run the DAG combiner in pre-legalize mode. // Run the DAG combiner in pre-legalize mode.
{ {
NamedRegionTimer T("DAG Combining 1", GroupName, TimePassesIsEnabled); NamedRegionTimer T("combine1", "DAG Combining 1", GroupName,
GroupDescription, TimePassesIsEnabled);
CurDAG->Combine(BeforeLegalizeTypes, *AA, OptLevel); CurDAG->Combine(BeforeLegalizeTypes, *AA, OptLevel);
} }
@ -769,7 +769,8 @@ void SelectionDAGISel::CodeGenAndEmitDAG() {
bool Changed; bool Changed;
{ {
NamedRegionTimer T("Type Legalization", GroupName, TimePassesIsEnabled); NamedRegionTimer T("legalize_types", "Type Legalization", GroupName,
GroupDescription, TimePassesIsEnabled);
Changed = CurDAG->LegalizeTypes(); Changed = CurDAG->LegalizeTypes();
} }
@ -784,8 +785,8 @@ void SelectionDAGISel::CodeGenAndEmitDAG() {
// Run the DAG combiner in post-type-legalize mode. // Run the DAG combiner in post-type-legalize mode.
{ {
NamedRegionTimer T("DAG Combining after legalize types", GroupName, NamedRegionTimer T("combine_lt", "DAG Combining after legalize types",
TimePassesIsEnabled); GroupName, GroupDescription, TimePassesIsEnabled);
CurDAG->Combine(AfterLegalizeTypes, *AA, OptLevel); CurDAG->Combine(AfterLegalizeTypes, *AA, OptLevel);
} }
@ -795,13 +796,15 @@ void SelectionDAGISel::CodeGenAndEmitDAG() {
} }
{ {
NamedRegionTimer T("Vector Legalization", GroupName, TimePassesIsEnabled); NamedRegionTimer T("legalize_vec", "Vector Legalization", GroupName,
GroupDescription, TimePassesIsEnabled);
Changed = CurDAG->LegalizeVectors(); Changed = CurDAG->LegalizeVectors();
} }
if (Changed) { if (Changed) {
{ {
NamedRegionTimer T("Type Legalization 2", GroupName, TimePassesIsEnabled); NamedRegionTimer T("legalize_types2", "Type Legalization 2", GroupName,
GroupDescription, TimePassesIsEnabled);
CurDAG->LegalizeTypes(); CurDAG->LegalizeTypes();
} }
@ -810,8 +813,8 @@ void SelectionDAGISel::CodeGenAndEmitDAG() {
// Run the DAG combiner in post-type-legalize mode. // Run the DAG combiner in post-type-legalize mode.
{ {
NamedRegionTimer T("DAG Combining after legalize vectors", GroupName, NamedRegionTimer T("combine_lv", "DAG Combining after legalize vectors",
TimePassesIsEnabled); GroupName, GroupDescription, TimePassesIsEnabled);
CurDAG->Combine(AfterLegalizeVectorOps, *AA, OptLevel); CurDAG->Combine(AfterLegalizeVectorOps, *AA, OptLevel);
} }
@ -823,7 +826,8 @@ void SelectionDAGISel::CodeGenAndEmitDAG() {
CurDAG->viewGraph("legalize input for " + BlockName); CurDAG->viewGraph("legalize input for " + BlockName);
{ {
NamedRegionTimer T("DAG Legalization", GroupName, TimePassesIsEnabled); NamedRegionTimer T("legalize", "DAG Legalization", GroupName,
GroupDescription, TimePassesIsEnabled);
CurDAG->Legalize(); CurDAG->Legalize();
} }
@ -835,7 +839,8 @@ void SelectionDAGISel::CodeGenAndEmitDAG() {
// Run the DAG combiner in post-legalize mode. // Run the DAG combiner in post-legalize mode.
{ {
NamedRegionTimer T("DAG Combining 2", GroupName, TimePassesIsEnabled); NamedRegionTimer T("combine2", "DAG Combining 2", GroupName,
GroupDescription, TimePassesIsEnabled);
CurDAG->Combine(AfterLegalizeDAG, *AA, OptLevel); CurDAG->Combine(AfterLegalizeDAG, *AA, OptLevel);
} }
@ -851,7 +856,8 @@ void SelectionDAGISel::CodeGenAndEmitDAG() {
// Third, instruction select all of the operations to machine code, adding the // Third, instruction select all of the operations to machine code, adding the
// code to the MachineBasicBlock. // code to the MachineBasicBlock.
{ {
NamedRegionTimer T("Instruction Selection", GroupName, TimePassesIsEnabled); NamedRegionTimer T("isel", "Instruction Selection", GroupName,
GroupDescription, TimePassesIsEnabled);
DoInstructionSelection(); DoInstructionSelection();
} }
@ -864,8 +870,8 @@ void SelectionDAGISel::CodeGenAndEmitDAG() {
// Schedule machine code. // Schedule machine code.
ScheduleDAGSDNodes *Scheduler = CreateScheduler(); ScheduleDAGSDNodes *Scheduler = CreateScheduler();
{ {
NamedRegionTimer T("Instruction Scheduling", GroupName, NamedRegionTimer T("sched", "Instruction Scheduling", GroupName,
TimePassesIsEnabled); GroupDescription, TimePassesIsEnabled);
Scheduler->Run(CurDAG, FuncInfo->MBB); Scheduler->Run(CurDAG, FuncInfo->MBB);
} }
@ -876,7 +882,8 @@ void SelectionDAGISel::CodeGenAndEmitDAG() {
// inserted into. // inserted into.
MachineBasicBlock *FirstMBB = FuncInfo->MBB, *LastMBB; MachineBasicBlock *FirstMBB = FuncInfo->MBB, *LastMBB;
{ {
NamedRegionTimer T("Instruction Creation", GroupName, TimePassesIsEnabled); NamedRegionTimer T("emit", "Instruction Creation", GroupName,
GroupDescription, TimePassesIsEnabled);
// FuncInfo->InsertPt is passed by reference and set to the end of the // FuncInfo->InsertPt is passed by reference and set to the end of the
// scheduled instructions. // scheduled instructions.
@ -890,8 +897,8 @@ void SelectionDAGISel::CodeGenAndEmitDAG() {
// Free the scheduler state. // Free the scheduler state.
{ {
NamedRegionTimer T("Instruction Scheduling Cleanup", GroupName, NamedRegionTimer T("cleanup", "Instruction Scheduling Cleanup", GroupName,
TimePassesIsEnabled); GroupDescription, TimePassesIsEnabled);
delete Scheduler; delete Scheduler;
} }

View File

@ -449,7 +449,7 @@ class TimingInfo {
TimerGroup TG; TimerGroup TG;
public: public:
// Use 'create' member to get this. // Use 'create' member to get this.
TimingInfo() : TG("... Pass execution timing report ...") {} TimingInfo() : TG("pass", "... Pass execution timing report ...") {}
// TimingDtor - Print out information about timing information // TimingDtor - Print out information about timing information
~TimingInfo() { ~TimingInfo() {
@ -472,8 +472,10 @@ public:
sys::SmartScopedLock<true> Lock(*TimingInfoMutex); sys::SmartScopedLock<true> Lock(*TimingInfoMutex);
Timer *&T = TimingData[P]; Timer *&T = TimingData[P];
if (!T) if (!T) {
T = new Timer(P->getPassName(), TG); StringRef PassName = P->getPassName();
T = new Timer(PassName, PassName, TG);
}
return T; return T;
} }
}; };

View File

@ -26,8 +26,10 @@ namespace llvm {
extern bool TimePassesIsEnabled; extern bool TimePassesIsEnabled;
} }
static const char *const TimeIRParsingGroupName = "LLVM IR Parsing"; static const char *const TimeIRParsingGroupName = "irparse";
static const char *const TimeIRParsingName = "Parse IR"; static const char *const TimeIRParsingGroupDescription = "LLVM IR Parsing";
static const char *const TimeIRParsingName = "parse";
static const char *const TimeIRParsingDescription = "Parse IR";
static std::unique_ptr<Module> static std::unique_ptr<Module>
getLazyIRModule(std::unique_ptr<MemoryBuffer> Buffer, SMDiagnostic &Err, getLazyIRModule(std::unique_ptr<MemoryBuffer> Buffer, SMDiagnostic &Err,
@ -67,7 +69,8 @@ std::unique_ptr<Module> llvm::getLazyIRFileModule(StringRef Filename,
std::unique_ptr<Module> llvm::parseIR(MemoryBufferRef Buffer, SMDiagnostic &Err, std::unique_ptr<Module> llvm::parseIR(MemoryBufferRef Buffer, SMDiagnostic &Err,
LLVMContext &Context) { LLVMContext &Context) {
NamedRegionTimer T(TimeIRParsingName, TimeIRParsingGroupName, NamedRegionTimer T(TimeIRParsingName, TimeIRParsingDescription,
TimeIRParsingGroupName, TimeIRParsingGroupDescription,
TimePassesIsEnabled); TimePassesIsEnabled);
if (isBitcode((const unsigned char *)Buffer.getBufferStart(), if (isBitcode((const unsigned char *)Buffer.getBufferStart(),
(const unsigned char *)Buffer.getBufferEnd())) { (const unsigned char *)Buffer.getBufferEnd())) {

View File

@ -81,7 +81,7 @@ static TimerGroup *getDefaultTimerGroup() {
sys::SmartScopedLock<true> Lock(*TimerLock); sys::SmartScopedLock<true> Lock(*TimerLock);
tmp = DefaultTimerGroup; tmp = DefaultTimerGroup;
if (!tmp) { if (!tmp) {
tmp = new TimerGroup("Miscellaneous Ungrouped Timers"); tmp = new TimerGroup("misc", "Miscellaneous Ungrouped Timers");
sys::MemoryFence(); sys::MemoryFence();
DefaultTimerGroup = tmp; DefaultTimerGroup = tmp;
} }
@ -93,13 +93,14 @@ static TimerGroup *getDefaultTimerGroup() {
// Timer Implementation // Timer Implementation
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
void Timer::init(StringRef N) { void Timer::init(StringRef Name, StringRef Description) {
init(N, *getDefaultTimerGroup()); init(Name, Description, *getDefaultTimerGroup());
} }
void Timer::init(StringRef N, TimerGroup &tg) { void Timer::init(StringRef Name, StringRef Description, TimerGroup &tg) {
assert(!TG && "Timer already initialized"); assert(!TG && "Timer already initialized");
Name.assign(N.begin(), N.end()); this->Name.assign(Name.begin(), Name.end());
this->Description.assign(Description.begin(), Description.end());
Running = Triggered = false; Running = Triggered = false;
TG = &tg; TG = &tg;
TG->addTimer(*this); TG->addTimer(*this);
@ -193,17 +194,18 @@ public:
delete I->second.first; delete I->second.first;
} }
Timer &get(StringRef Name, StringRef GroupName) { Timer &get(StringRef Name, StringRef Description, StringRef GroupName,
StringRef GroupDescription) {
sys::SmartScopedLock<true> L(*TimerLock); sys::SmartScopedLock<true> L(*TimerLock);
std::pair<TimerGroup*, Name2TimerMap> &GroupEntry = Map[GroupName]; std::pair<TimerGroup*, Name2TimerMap> &GroupEntry = Map[GroupName];
if (!GroupEntry.first) if (!GroupEntry.first)
GroupEntry.first = new TimerGroup(GroupName); GroupEntry.first = new TimerGroup(GroupName, GroupDescription);
Timer &T = GroupEntry.second[Name]; Timer &T = GroupEntry.second[Name];
if (!T.isInitialized()) if (!T.isInitialized())
T.init(Name, *GroupEntry.first); T.init(Name, Description, *GroupEntry.first);
return T; return T;
} }
}; };
@ -212,9 +214,12 @@ public:
static ManagedStatic<Name2PairMap> NamedGroupedTimers; static ManagedStatic<Name2PairMap> NamedGroupedTimers;
NamedRegionTimer::NamedRegionTimer(StringRef Name, StringRef GroupName, NamedRegionTimer::NamedRegionTimer(StringRef Name, StringRef Description,
bool Enabled) StringRef GroupName,
: TimeRegion(!Enabled ? nullptr : &NamedGroupedTimers->get(Name, GroupName)){} StringRef GroupDescription, bool Enabled)
: TimeRegion(!Enabled ? nullptr
: &NamedGroupedTimers->get(Name, Description, GroupName,
GroupDescription)) {}
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// TimerGroup Implementation // TimerGroup Implementation
@ -224,9 +229,9 @@ NamedRegionTimer::NamedRegionTimer(StringRef Name, StringRef GroupName,
/// ctor/dtor and is protected by the TimerLock lock. /// ctor/dtor and is protected by the TimerLock lock.
static TimerGroup *TimerGroupList = nullptr; static TimerGroup *TimerGroupList = nullptr;
TimerGroup::TimerGroup(StringRef name) TimerGroup::TimerGroup(StringRef Name, StringRef Description)
: Name(name.begin(), name.end()) { : Name(Name.begin(), Name.end()),
Description(Description.begin(), Description.end()) {
// Add the group to TimerGroupList. // Add the group to TimerGroupList.
sys::SmartScopedLock<true> L(*TimerLock); sys::SmartScopedLock<true> L(*TimerLock);
if (TimerGroupList) if (TimerGroupList)
@ -255,7 +260,7 @@ void TimerGroup::removeTimer(Timer &T) {
// If the timer was started, move its data to TimersToPrint. // If the timer was started, move its data to TimersToPrint.
if (T.hasTriggered()) if (T.hasTriggered())
TimersToPrint.emplace_back(T.Time, T.Name); TimersToPrint.emplace_back(T.Time, T.Description);
T.TG = nullptr; T.TG = nullptr;
@ -295,9 +300,9 @@ void TimerGroup::PrintQueuedTimers(raw_ostream &OS) {
// Print out timing header. // Print out timing header.
OS << "===" << std::string(73, '-') << "===\n"; OS << "===" << std::string(73, '-') << "===\n";
// Figure out how many spaces to indent TimerGroup name. // Figure out how many spaces to indent TimerGroup name.
unsigned Padding = (80-Name.length())/2; unsigned Padding = (80-Description.length())/2;
if (Padding > 80) Padding = 0; // Don't allow "negative" numbers if (Padding > 80) Padding = 0; // Don't allow "negative" numbers
OS.indent(Padding) << Name << '\n'; OS.indent(Padding) << Description << '\n';
OS << "===" << std::string(73, '-') << "===\n"; OS << "===" << std::string(73, '-') << "===\n";
// If this is not an collection of ungrouped times, print the total time. // If this is not an collection of ungrouped times, print the total time.
@ -340,7 +345,7 @@ void TimerGroup::print(raw_ostream &OS) {
// reset them. // reset them.
for (Timer *T = FirstTimer; T; T = T->Next) { for (Timer *T = FirstTimer; T; T = T->Next) {
if (!T->hasTriggered()) continue; if (!T->hasTriggered()) continue;
TimersToPrint.emplace_back(T->Time, T->Name); TimersToPrint.emplace_back(T->Time, T->Description);
// Clear out the time. // Clear out the time.
T->clear(); T->clear();

View File

@ -1519,8 +1519,12 @@ bool HexagonGenInsert::runOnMachineFunction(MachineFunction &MF) {
MachineBasicBlock *RootB = MDT->getRoot(); MachineBasicBlock *RootB = MDT->getRoot();
OrderedRegisterList AvailR(CellOrd); OrderedRegisterList AvailR(CellOrd);
const char *const TGName = "hexinsert";
const char *const TGDesc = "Generate Insert Instructions";
{ {
NamedRegionTimer _T("collection", "hexinsert", TimingDetail); NamedRegionTimer _T("collection", "collection", TGName, TGDesc,
TimingDetail);
collectInBlock(RootB, AvailR); collectInBlock(RootB, AvailR);
// Complete the information gathered in IFMap. // Complete the information gathered in IFMap.
computeRemovableRegisters(); computeRemovableRegisters();
@ -1535,7 +1539,7 @@ bool HexagonGenInsert::runOnMachineFunction(MachineFunction &MF) {
return Changed; return Changed;
{ {
NamedRegionTimer _T("pruning", "hexinsert", TimingDetail); NamedRegionTimer _T("pruning", "pruning", TGName, TGDesc, TimingDetail);
pruneCandidates(); pruneCandidates();
} }
@ -1548,7 +1552,7 @@ bool HexagonGenInsert::runOnMachineFunction(MachineFunction &MF) {
return Changed; return Changed;
{ {
NamedRegionTimer _T("selection", "hexinsert", TimingDetail); NamedRegionTimer _T("selection", "selection", TGName, TGDesc, TimingDetail);
selectCandidates(); selectCandidates();
} }
@ -1574,7 +1578,8 @@ bool HexagonGenInsert::runOnMachineFunction(MachineFunction &MF) {
return Changed; return Changed;
{ {
NamedRegionTimer _T("generation", "hexinsert", TimingDetail); NamedRegionTimer _T("generation", "generation", TGName, TGDesc,
TimingDetail);
generateInserts(); generateInserts();
} }

View File

@ -753,8 +753,7 @@ void RegisterAggr::print(raw_ostream &OS) const {
DataFlowGraph::DataFlowGraph(MachineFunction &mf, const TargetInstrInfo &tii, DataFlowGraph::DataFlowGraph(MachineFunction &mf, const TargetInstrInfo &tii,
const TargetRegisterInfo &tri, const MachineDominatorTree &mdt, const TargetRegisterInfo &tri, const MachineDominatorTree &mdt,
const MachineDominanceFrontier &mdf, const TargetOperandInfo &toi) const MachineDominanceFrontier &mdf, const TargetOperandInfo &toi)
: TimeG("rdf"), LMI(), MF(mf), TII(tii), TRI(tri), MDT(mdt), MDF(mdf), : LMI(), MF(mf), TII(tii), TRI(tri), MDT(mdt), MDF(mdf), TOI(toi) {
TOI(toi) {
} }

View File

@ -911,7 +911,6 @@ namespace rdf {
return BlockNodes[BB]; return BlockNodes[BB];
} }
TimerGroup TimeG;
NodeAddr<FuncNode*> Func; NodeAddr<FuncNode*> Func;
NodeAllocator Memory; NodeAllocator Memory;
// Local map: MachineBasicBlock -> NodeAddr<BlockNode*> // Local map: MachineBasicBlock -> NodeAddr<BlockNode*>

View File

@ -33,7 +33,7 @@ void SleepMS() {
} }
TEST(Timer, Additivity) { TEST(Timer, Additivity) {
Timer T1("T1"); Timer T1("T1", "T1");
EXPECT_TRUE(T1.isInitialized()); EXPECT_TRUE(T1.isInitialized());
@ -50,7 +50,7 @@ TEST(Timer, Additivity) {
} }
TEST(Timer, CheckIfTriggered) { TEST(Timer, CheckIfTriggered) {
Timer T1("T1"); Timer T1("T1", "T1");
EXPECT_FALSE(T1.hasTriggered()); EXPECT_FALSE(T1.hasTriggered());
T1.startTimer(); T1.startTimer();

View File

@ -143,10 +143,10 @@ static void dumpStream(yaml::Stream &stream) {
} }
} }
static void benchmark( llvm::TimerGroup &Group static void benchmark(llvm::TimerGroup &Group, llvm::StringRef Name,
, llvm::StringRef Name llvm::StringRef Description, llvm::StringRef JSONText) {
, llvm::StringRef JSONText) { llvm::Timer BaseLine((Name + ".loop").str(), (Description + ": Loop").str(),
llvm::Timer BaseLine((Name + ": Loop").str(), Group); Group);
BaseLine.startTimer(); BaseLine.startTimer();
char C = 0; char C = 0;
for (llvm::StringRef::iterator I = JSONText.begin(), for (llvm::StringRef::iterator I = JSONText.begin(),
@ -155,14 +155,16 @@ static void benchmark( llvm::TimerGroup &Group
BaseLine.stopTimer(); BaseLine.stopTimer();
volatile char DontOptimizeOut = C; (void)DontOptimizeOut; volatile char DontOptimizeOut = C; (void)DontOptimizeOut;
llvm::Timer Tokenizing((Name + ": Tokenizing").str(), Group); llvm::Timer Tokenizing((Name + ".tokenizing").str(),
(Description + ": Tokenizing").str(), Group);
Tokenizing.startTimer(); Tokenizing.startTimer();
{ {
yaml::scanTokens(JSONText); yaml::scanTokens(JSONText);
} }
Tokenizing.stopTimer(); Tokenizing.stopTimer();
llvm::Timer Parsing((Name + ": Parsing").str(), Group); llvm::Timer Parsing((Name + ".parsing").str(),
(Description + ": Parsing").str(), Group);
Parsing.startTimer(); Parsing.startTimer();
{ {
llvm::SourceMgr SM; llvm::SourceMgr SM;
@ -218,13 +220,15 @@ int main(int argc, char **argv) {
} }
if (Verify) { if (Verify) {
llvm::TimerGroup Group("YAML parser benchmark"); llvm::TimerGroup Group("yaml", "YAML parser benchmark");
benchmark(Group, "Fast", createJSONText(10, 500)); benchmark(Group, "Fast", "Fast", createJSONText(10, 500));
} else if (!DumpCanonical && !DumpTokens) { } else if (!DumpCanonical && !DumpTokens) {
llvm::TimerGroup Group("YAML parser benchmark"); llvm::TimerGroup Group("yaml", "YAML parser benchmark");
benchmark(Group, "Small Values", createJSONText(MemoryLimitMB, 5)); benchmark(Group, "Small", "Small Values", createJSONText(MemoryLimitMB, 5));
benchmark(Group, "Medium Values", createJSONText(MemoryLimitMB, 500)); benchmark(Group, "Medium", "Medium Values",
benchmark(Group, "Large Values", createJSONText(MemoryLimitMB, 50000)); createJSONText(MemoryLimitMB, 500));
benchmark(Group, "Large", "Large Values",
createJSONText(MemoryLimitMB, 50000));
} }
return 0; return 0;