Index: docs/ReleaseNotes.rst =================================================================== --- docs/ReleaseNotes.rst +++ docs/ReleaseNotes.rst @@ -41,7 +41,9 @@ functionality, or simply have a lot to talk about), see the `NOTE` below for adding a new subsection. -* ... next change ... +* 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. .. NOTE If you would like to document a larger change, then you can add a Index: include/llvm/CodeGen/AsmPrinter.h =================================================================== --- include/llvm/CodeGen/AsmPrinter.h +++ include/llvm/CodeGen/AsmPrinter.h @@ -122,11 +122,16 @@ struct HandlerInfo { AsmPrinterHandler *Handler; - const char *TimerName, *TimerGroupName; + const char *TimerName; + const char *TimerDescription; + const char *TimerGroupName; + const char *TimerGroupDescription; HandlerInfo(AsmPrinterHandler *Handler, const char *TimerName, - const char *TimerGroupName) + const char *TimerDescription, const char *TimerGroupName, + const char *TimerGroupDescription) : 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 /// maintains ownership of the emitters. Index: include/llvm/Support/Timer.h =================================================================== --- include/llvm/Support/Timer.h +++ include/llvm/Support/Timer.h @@ -77,6 +77,7 @@ TimeRecord Time; ///< The total time captured. TimeRecord StartTime; ///< The time startTimer() was last called. 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 Triggered; ///< Has the timer ever been triggered? TimerGroup *TG = nullptr; ///< The TimerGroup this Timer is in. @@ -84,8 +85,12 @@ Timer **Prev; ///< Pointer to \p Next of previous timer in group. Timer *Next; ///< Next timer in the group. public: - explicit Timer(StringRef N) { init(N); } - Timer(StringRef N, TimerGroup &tg) { init(N, tg); } + explicit Timer(StringRef Name, StringRef Description) { + init(Name, Description); + } + Timer(StringRef Name, StringRef Description, TimerGroup &tg) { + init(Name, Description, tg); + } Timer(const Timer &RHS) { assert(!RHS.TG && "Can only copy uninitialized timers"); } @@ -97,10 +102,11 @@ /// Create an uninitialized timer, client must use 'init'. explicit Timer() {} - void init(StringRef N); - void init(StringRef N, TimerGroup &tg); + void init(StringRef Name, StringRef Description); + void init(StringRef Name, StringRef Description, TimerGroup &tg); const std::string &getName() const { return Name; } + const std::string &getDescription() const { return Description; } bool isInitialized() const { return TG != nullptr; } /// Check if the timer is currently running. @@ -152,10 +158,9 @@ /// statement. All timers with the same name are merged. This is primarily /// used for debugging and for hunting performance problems. struct NamedRegionTimer : public TimeRegion { - explicit NamedRegionTimer(StringRef Name, - bool Enabled = true); - explicit NamedRegionTimer(StringRef Name, StringRef GroupName, - bool Enabled = true); + explicit NamedRegionTimer(StringRef Name, StringRef Description, + StringRef GroupName, + StringRef GroupDescription, bool Enabled = true); }; /// The TimerGroup class is used to group together related timers into a single @@ -164,6 +169,7 @@ /// TimerGroup can be specified for a newly created timer in its constructor. class TimerGroup { std::string Name; + std::string Description; Timer *FirstTimer = nullptr; ///< First timer in the group. std::vector> TimersToPrint; @@ -173,10 +179,13 @@ void operator=(const TimerGroup &TG) = delete; public: - explicit TimerGroup(StringRef name); + explicit TimerGroup(StringRef Name, StringRef Description); ~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. void print(raw_ostream &OS); Index: lib/CodeGen/AsmPrinter/AsmPrinter.cpp =================================================================== --- lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -55,10 +55,15 @@ #define DEBUG_TYPE "asm-printer" -static const char *const DWARFGroupName = "DWARF Emission"; -static const char *const DbgTimerName = "Debug Info Emission"; -static const char *const EHTimerName = "DWARF Exception Writer"; -static const char *const CodeViewLineTablesGroupName = "CodeView Line Tables"; +static const char *const DWARFGroupName = "dwarf"; +static const char *const DWARFGroupDescription = "DWARF Emission"; +static const char *const DbgTimerName = "emit"; +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"); @@ -244,13 +249,15 @@ bool EmitCodeView = MMI->getModule()->getCodeViewFlag(); if (EmitCodeView && TM.getTargetTriple().isKnownWindowsMSVCEnvironment()) { Handlers.push_back(HandlerInfo(new CodeViewDebug(this), - DbgTimerName, - CodeViewLineTablesGroupName)); + DbgTimerName, DbgTimerDescription, + CodeViewLineTablesGroupName, + CodeViewLineTablesGroupDescription)); } if (!EmitCodeView || MMI->getModule()->getDwarfVersion()) { DD = new DwarfDebug(this, &M); DD->beginModule(); - Handlers.push_back(HandlerInfo(DD, DbgTimerName, DWARFGroupName)); + Handlers.push_back(HandlerInfo(DD, DbgTimerName, DbgTimerDescription, + DWARFGroupName, DWARFGroupDescription)); } } @@ -278,7 +285,8 @@ break; } if (ES) - Handlers.push_back(HandlerInfo(ES, EHTimerName, DWARFGroupName)); + Handlers.push_back(HandlerInfo(ES, EHTimerName, EHTimerDescription, + DWARFGroupName, DWARFGroupDescription)); return false; } @@ -399,7 +407,9 @@ unsigned AlignLog = getGVAlignmentLog2(GV, DL); 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); } @@ -588,7 +598,8 @@ // Emit pre-function debug and/or EH information. 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); } @@ -852,7 +863,8 @@ if (ShouldPrintDebugScopes) { for (const HandlerInfo &HI : Handlers) { - NamedRegionTimer T(HI.TimerName, HI.TimerGroupName, + NamedRegionTimer T(HI.TimerName, HI.TimerDescription, + HI.TimerGroupName, HI.TimerGroupDescription, TimePassesIsEnabled); HI.Handler->beginInstruction(&MI); } @@ -896,7 +908,8 @@ if (ShouldPrintDebugScopes) { for (const HandlerInfo &HI : Handlers) { - NamedRegionTimer T(HI.TimerName, HI.TimerGroupName, + NamedRegionTimer T(HI.TimerName, HI.TimerDescription, + HI.TimerGroupName, HI.TimerGroupDescription, TimePassesIsEnabled); HI.Handler->endInstruction(); } @@ -954,7 +967,8 @@ } 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(); } @@ -963,7 +977,8 @@ // Emit post-function debug and/or EH information. 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); } MMI->EndFunction(); @@ -1154,8 +1169,8 @@ // Finalize debug and EH information. 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->endModule(); delete HI.Handler; } Index: lib/CodeGen/AsmPrinter/DwarfDebug.cpp =================================================================== --- lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -120,8 +120,10 @@ "Abstract subprograms")), cl::init(DefaultLinkageNames)); -static const char *const DWARFGroupName = "DWARF Emission"; -static const char *const DbgTimerName = "DWARF Debug Writer"; +static const char *const DWARFGroupName = "dwarf"; +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) { BS.EmitInt8( @@ -464,7 +466,8 @@ // global DIEs and emit initial debug info sections. This is invoked by // the target AsmPrinter. void DwarfDebug::beginModule() { - NamedRegionTimer T(DbgTimerName, DWARFGroupName, TimePassesIsEnabled); + NamedRegionTimer T(DbgTimerName, DbgTimerDescription, DWARFGroupName, + DWARFGroupDescription, TimePassesIsEnabled); if (DisableDebugInfoPrinting) return; Index: lib/CodeGen/RegAllocBase.h =================================================================== --- lib/CodeGen/RegAllocBase.h +++ lib/CodeGen/RegAllocBase.h @@ -105,6 +105,7 @@ // Use this group name for NamedRegionTimer. static const char TimerGroupName[]; + static const char TimerGroupDescription[]; /// Method called when the allocator is about to remove a LiveInterval. virtual void aboutToRemoveInterval(LiveInterval &LI) {} Index: lib/CodeGen/RegAllocBase.cpp =================================================================== --- lib/CodeGen/RegAllocBase.cpp +++ lib/CodeGen/RegAllocBase.cpp @@ -41,7 +41,8 @@ VerifyRegAlloc("verify-regalloc", cl::location(RegAllocBase::VerifyEnabled), 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; //===----------------------------------------------------------------------===// @@ -67,7 +68,8 @@ // register, unify them with the corresponding LiveIntervalUnion, otherwise push // them on the priority queue for later assignment. 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) { unsigned Reg = TargetRegisterInfo::index2VirtReg(i); if (MRI->reg_nodbg_empty(Reg)) Index: lib/CodeGen/RegAllocGreedy.cpp =================================================================== --- lib/CodeGen/RegAllocGreedy.cpp +++ lib/CodeGen/RegAllocGreedy.cpp @@ -861,7 +861,8 @@ AllocationOrder &Order, SmallVectorImpl &NewVRegs, unsigned CostPerUseLimit) { - NamedRegionTimer T("Evict", TimerGroupName, TimePassesIsEnabled); + NamedRegionTimer T("evict", "Evict", TimerGroupName, TimerGroupDescription, + TimePassesIsEnabled); // Keep track of the cheapest interference seen so far. EvictionCost BestCost; @@ -1959,7 +1960,8 @@ // Local intervals are handled separately. if (LIS->intervalIsInOneMBB(VirtReg)) { - NamedRegionTimer T("Local Splitting", TimerGroupName, TimePassesIsEnabled); + NamedRegionTimer T("local_split", "Local Splitting", TimerGroupName, + TimerGroupDescription, TimePassesIsEnabled); SA->analyze(&VirtReg); unsigned PhysReg = tryLocalSplit(VirtReg, Order, NewVRegs); if (PhysReg || !NewVRegs.empty()) @@ -1967,7 +1969,8 @@ return tryInstructionSplit(VirtReg, Order, NewVRegs); } - NamedRegionTimer T("Global Splitting", TimerGroupName, TimePassesIsEnabled); + NamedRegionTimer T("global_split", "Global Splitting", TimerGroupName, + TimerGroupDescription, TimePassesIsEnabled); SA->analyze(&VirtReg); @@ -2577,7 +2580,8 @@ DEBUG(dbgs() << "Do as if this register is in memory\n"); NewVRegs.push_back(VirtReg.reg); } else { - NamedRegionTimer T("Spiller", TimerGroupName, TimePassesIsEnabled); + NamedRegionTimer T("spill", "Spiller", TimerGroupName, + TimerGroupDescription, TimePassesIsEnabled); LiveRangeEdit LRE(&VirtReg, NewVRegs, *MF, *LIS, VRM, this, &DeadRemats); spiller().spill(LRE); setStage(NewVRegs.begin(), NewVRegs.end(), RS_Done); Index: lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp =================================================================== --- lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -725,9 +725,8 @@ } void SelectionDAGISel::CodeGenAndEmitDAG() { - std::string GroupName; - if (TimePassesIsEnabled) - GroupName = "Instruction Selection and Scheduling"; + StringRef GroupName = "sdag"; + StringRef GroupDescription = "Instruction Selection and Scheduling"; std::string BlockName; int BlockNumber = -1; (void)BlockNumber; @@ -755,7 +754,8 @@ // 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); } @@ -769,7 +769,8 @@ bool Changed; { - NamedRegionTimer T("Type Legalization", GroupName, TimePassesIsEnabled); + NamedRegionTimer T("legalize_types", "Type Legalization", GroupName, + GroupDescription, TimePassesIsEnabled); Changed = CurDAG->LegalizeTypes(); } @@ -784,8 +785,8 @@ // Run the DAG combiner in post-type-legalize mode. { - NamedRegionTimer T("DAG Combining after legalize types", GroupName, - TimePassesIsEnabled); + NamedRegionTimer T("combine_lt", "DAG Combining after legalize types", + GroupName, GroupDescription, TimePassesIsEnabled); CurDAG->Combine(AfterLegalizeTypes, *AA, OptLevel); } @@ -795,13 +796,15 @@ } { - NamedRegionTimer T("Vector Legalization", GroupName, TimePassesIsEnabled); + NamedRegionTimer T("legalize_vec", "Vector Legalization", GroupName, + GroupDescription, TimePassesIsEnabled); Changed = CurDAG->LegalizeVectors(); } if (Changed) { { - NamedRegionTimer T("Type Legalization 2", GroupName, TimePassesIsEnabled); + NamedRegionTimer T("legalize_types2", "Type Legalization 2", GroupName, + GroupDescription, TimePassesIsEnabled); CurDAG->LegalizeTypes(); } @@ -810,8 +813,8 @@ // Run the DAG combiner in post-type-legalize mode. { - NamedRegionTimer T("DAG Combining after legalize vectors", GroupName, - TimePassesIsEnabled); + NamedRegionTimer T("combine_lv", "DAG Combining after legalize vectors", + GroupName, GroupDescription, TimePassesIsEnabled); CurDAG->Combine(AfterLegalizeVectorOps, *AA, OptLevel); } @@ -823,7 +826,8 @@ CurDAG->viewGraph("legalize input for " + BlockName); { - NamedRegionTimer T("DAG Legalization", GroupName, TimePassesIsEnabled); + NamedRegionTimer T("legalize", "DAG Legalization", GroupName, + GroupDescription, TimePassesIsEnabled); CurDAG->Legalize(); } @@ -835,7 +839,8 @@ // 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); } @@ -851,7 +856,8 @@ // Third, instruction select all of the operations to machine code, adding the // code to the MachineBasicBlock. { - NamedRegionTimer T("Instruction Selection", GroupName, TimePassesIsEnabled); + NamedRegionTimer T("isel", "Instruction Selection", GroupName, + GroupDescription, TimePassesIsEnabled); DoInstructionSelection(); } @@ -864,8 +870,8 @@ // Schedule machine code. ScheduleDAGSDNodes *Scheduler = CreateScheduler(); { - NamedRegionTimer T("Instruction Scheduling", GroupName, - TimePassesIsEnabled); + NamedRegionTimer T("sched", "Instruction Scheduling", GroupName, + GroupDescription, TimePassesIsEnabled); Scheduler->Run(CurDAG, FuncInfo->MBB); } @@ -876,7 +882,8 @@ // inserted into. 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 // scheduled instructions. @@ -890,8 +897,8 @@ // Free the scheduler state. { - NamedRegionTimer T("Instruction Scheduling Cleanup", GroupName, - TimePassesIsEnabled); + NamedRegionTimer T("cleanup", "Instruction Scheduling Cleanup", GroupName, + GroupDescription, TimePassesIsEnabled); delete Scheduler; } Index: lib/IR/LegacyPassManager.cpp =================================================================== --- lib/IR/LegacyPassManager.cpp +++ lib/IR/LegacyPassManager.cpp @@ -449,7 +449,7 @@ TimerGroup TG; public: // 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 ~TimingInfo() { @@ -472,8 +472,10 @@ sys::SmartScopedLock Lock(*TimingInfoMutex); Timer *&T = TimingData[P]; - if (!T) - T = new Timer(P->getPassName(), TG); + if (!T) { + StringRef PassName = P->getPassName(); + T = new Timer(PassName, PassName, TG); + } return T; } }; Index: lib/IRReader/IRReader.cpp =================================================================== --- lib/IRReader/IRReader.cpp +++ lib/IRReader/IRReader.cpp @@ -26,8 +26,10 @@ extern bool TimePassesIsEnabled; } -static const char *const TimeIRParsingGroupName = "LLVM IR Parsing"; -static const char *const TimeIRParsingName = "Parse IR"; +static const char *const TimeIRParsingGroupName = "irparse"; +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 getLazyIRModule(std::unique_ptr Buffer, SMDiagnostic &Err, @@ -65,7 +67,8 @@ std::unique_ptr llvm::parseIR(MemoryBufferRef Buffer, SMDiagnostic &Err, LLVMContext &Context) { - NamedRegionTimer T(TimeIRParsingName, TimeIRParsingGroupName, + NamedRegionTimer T(TimeIRParsingName, TimeIRParsingDescription, + TimeIRParsingGroupName, TimeIRParsingGroupDescription, TimePassesIsEnabled); if (isBitcode((const unsigned char *)Buffer.getBufferStart(), (const unsigned char *)Buffer.getBufferEnd())) { Index: lib/Support/Timer.cpp =================================================================== --- lib/Support/Timer.cpp +++ lib/Support/Timer.cpp @@ -81,7 +81,7 @@ sys::SmartScopedLock Lock(*TimerLock); tmp = DefaultTimerGroup; if (!tmp) { - tmp = new TimerGroup("Miscellaneous Ungrouped Timers"); + tmp = new TimerGroup("Misc", "Miscellaneous Ungrouped Timers"); sys::MemoryFence(); DefaultTimerGroup = tmp; } @@ -93,13 +93,14 @@ // Timer Implementation //===----------------------------------------------------------------------===// -void Timer::init(StringRef N) { - init(N, *getDefaultTimerGroup()); +void Timer::init(StringRef Name, StringRef Description) { + 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"); - Name.assign(N.begin(), N.end()); + this->Name.assign(Name.begin(), Name.end()); + this->Description.assign(Description.begin(), Description.end()); Running = Triggered = false; TG = &tg; TG->addTimer(*this); @@ -191,42 +192,32 @@ delete I->second.first; } - Timer &get(StringRef Name, StringRef GroupName) { + Timer &get(StringRef Name, StringRef Description, StringRef GroupName, + StringRef GroupDescription) { sys::SmartScopedLock L(*TimerLock); std::pair &GroupEntry = Map[GroupName]; if (!GroupEntry.first) - GroupEntry.first = new TimerGroup(GroupName); + GroupEntry.first = new TimerGroup(GroupName, GroupDescription); Timer &T = GroupEntry.second[Name]; if (!T.isInitialized()) - T.init(Name, *GroupEntry.first); + T.init(Name, Description, *GroupEntry.first); return T; } }; } -static ManagedStatic NamedTimers; static ManagedStatic NamedGroupedTimers; -static Timer &getNamedRegionTimer(StringRef Name) { - sys::SmartScopedLock L(*TimerLock); - - Timer &T = (*NamedTimers)[Name]; - if (!T.isInitialized()) - T.init(Name); - return T; -} - -NamedRegionTimer::NamedRegionTimer(StringRef Name, - bool Enabled) - : TimeRegion(!Enabled ? nullptr : &getNamedRegionTimer(Name)) {} - -NamedRegionTimer::NamedRegionTimer(StringRef Name, StringRef GroupName, - bool Enabled) - : TimeRegion(!Enabled ? nullptr : &NamedGroupedTimers->get(Name, GroupName)){} +NamedRegionTimer::NamedRegionTimer(StringRef Name, StringRef Description, + StringRef GroupName, + StringRef GroupDescription, bool Enabled) + : TimeRegion(!Enabled ? nullptr + : &NamedGroupedTimers->get(Name, Description, GroupName, + GroupDescription)) {} //===----------------------------------------------------------------------===// // TimerGroup Implementation @@ -236,9 +227,9 @@ /// ctor/dtor and is protected by the TimerLock lock. static TimerGroup *TimerGroupList = nullptr; -TimerGroup::TimerGroup(StringRef name) - : Name(name.begin(), name.end()) { - +TimerGroup::TimerGroup(StringRef Name, StringRef Description) + : Name(Name.begin(), Name.end()), + Description(Description.begin(), Description.end()) { // Add the group to TimerGroupList. sys::SmartScopedLock L(*TimerLock); if (TimerGroupList) @@ -267,7 +258,7 @@ // If the timer was started, move its data to TimersToPrint. if (T.hasTriggered()) - TimersToPrint.emplace_back(T.Time, T.Name); + TimersToPrint.emplace_back(T.Time, T.Description); T.TG = nullptr; @@ -307,9 +298,9 @@ // Print out timing header. OS << "===" << std::string(73, '-') << "===\n"; // 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 - OS.indent(Padding) << Name << '\n'; + OS.indent(Padding) << Description << '\n'; OS << "===" << std::string(73, '-') << "===\n"; // If this is not an collection of ungrouped times, print the total time. @@ -352,7 +343,7 @@ // reset them. for (Timer *T = FirstTimer; T; T = T->Next) { if (!T->hasTriggered()) continue; - TimersToPrint.emplace_back(T->Time, T->Name); + TimersToPrint.emplace_back(T->Time, T->Description); // Clear out the time. T->clear(); Index: utils/yaml-bench/YAMLBench.cpp =================================================================== --- utils/yaml-bench/YAMLBench.cpp +++ utils/yaml-bench/YAMLBench.cpp @@ -143,10 +143,10 @@ } } -static void benchmark( llvm::TimerGroup &Group - , llvm::StringRef Name - , llvm::StringRef JSONText) { - llvm::Timer BaseLine((Name + ": Loop").str(), Group); +static void benchmark(llvm::TimerGroup &Group, llvm::StringRef Name, + llvm::StringRef Description, llvm::StringRef JSONText) { + llvm::Timer BaseLine((Name + ".loop").str(), (Description + ": Loop").str(), + Group); BaseLine.startTimer(); char C = 0; for (llvm::StringRef::iterator I = JSONText.begin(), @@ -155,14 +155,16 @@ BaseLine.stopTimer(); 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(); { yaml::scanTokens(JSONText); } Tokenizing.stopTimer(); - llvm::Timer Parsing((Name + ": Parsing").str(), Group); + llvm::Timer Parsing((Name + ".parsing").str(), + (Description + ": Parsing").str(), Group); Parsing.startTimer(); { llvm::SourceMgr SM; @@ -218,13 +220,15 @@ } if (Verify) { - llvm::TimerGroup Group("YAML parser benchmark"); - benchmark(Group, "Fast", createJSONText(10, 500)); + llvm::TimerGroup Group("yaml", "YAML parser benchmark"); + benchmark(Group, "Fast", "Fast", createJSONText(10, 500)); } else if (!DumpCanonical && !DumpTokens) { - llvm::TimerGroup Group("YAML parser benchmark"); - benchmark(Group, "Small Values", createJSONText(MemoryLimitMB, 5)); - benchmark(Group, "Medium Values", createJSONText(MemoryLimitMB, 500)); - benchmark(Group, "Large Values", createJSONText(MemoryLimitMB, 50000)); + llvm::TimerGroup Group("yaml", "YAML parser benchmark"); + benchmark(Group, "Small", "Small Values", createJSONText(MemoryLimitMB, 5)); + benchmark(Group, "Medium", "Medium Values", + createJSONText(MemoryLimitMB, 500)); + benchmark(Group, "Large", "Large Values", + createJSONText(MemoryLimitMB, 50000)); } return 0;