llvm.org GIT mirror llvm / 9262f00
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287369 91177308-0d34-0410-b5e6-96231b3b80d8 Matthias Braun 2 years ago
17 changed file(s) with 171 addition(s) and 102 deletion(s). Raw diff Collapse all Expand all
5151 semantics rather than gcc's __attribute__((warn_unused_result)).
5252
5353 * Minimum compiler version to build has been raised to GCC 4.8 and VS 2015.
54
55 * The Timer related APIs now expect a Name and Description. When upgrading code
56 the previously used names should become descriptions and a short name in the
57 style of a programming language identifier should be added.
5458
5559 * ... next change ...
5660
121121
122122 struct HandlerInfo {
123123 AsmPrinterHandler *Handler;
124 const char *TimerName, *TimerGroupName;
124 const char *TimerName;
125 const char *TimerDescription;
126 const char *TimerGroupName;
127 const char *TimerGroupDescription;
125128 HandlerInfo(AsmPrinterHandler *Handler, const char *TimerName,
126 const char *TimerGroupName)
129 const char *TimerDescription, const char *TimerGroupName,
130 const char *TimerGroupDescription)
127131 : Handler(Handler), TimerName(TimerName),
128 TimerGroupName(TimerGroupName) {}
132 TimerDescription(TimerDescription), TimerGroupName(TimerGroupName),
133 TimerGroupDescription(TimerGroupDescription) {}
129134 };
130135 /// A vector of all debug/EH info emitters we should use. This vector
131136 /// maintains ownership of the emitters.
7676 TimeRecord Time; ///< The total time captured.
7777 TimeRecord StartTime; ///< The time startTimer() was last called.
7878 std::string Name; ///< The name of this time variable.
79 std::string Description; ///< Description of this time variable.
7980 bool Running; ///< Is the timer currently running?
8081 bool Triggered; ///< Has the timer ever been triggered?
8182 TimerGroup *TG = nullptr; ///< The TimerGroup this Timer is in.
8384 Timer **Prev; ///< Pointer to \p Next of previous timer in group.
8485 Timer *Next; ///< Next timer in the group.
8586 public:
86 explicit Timer(StringRef N) { init(N); }
87 Timer(StringRef N, TimerGroup &tg) { init(N, tg); }
87 explicit Timer(StringRef Name, StringRef Description) {
88 init(Name, Description);
89 }
90 Timer(StringRef Name, StringRef Description, TimerGroup &tg) {
91 init(Name, Description, tg);
92 }
8893 Timer(const Timer &RHS) {
8994 assert(!RHS.TG && "Can only copy uninitialized timers");
9095 }
96101
97102 /// Create an uninitialized timer, client must use 'init'.
98103 explicit Timer() {}
99 void init(StringRef N);
100 void init(StringRef N, TimerGroup &tg);
104 void init(StringRef Name, StringRef Description);
105 void init(StringRef Name, StringRef Description, TimerGroup &tg);
101106
102107 const std::string &getName() const { return Name; }
108 const std::string &getDescription() const { return Description; }
103109 bool isInitialized() const { return TG != nullptr; }
104110
105111 /// Check if the timer is currently running.
151157 /// statement. All timers with the same name are merged. This is primarily
152158 /// used for debugging and for hunting performance problems.
153159 struct NamedRegionTimer : public TimeRegion {
154 explicit NamedRegionTimer(StringRef Name, StringRef GroupName,
155 bool Enabled = true);
160 explicit NamedRegionTimer(StringRef Name, StringRef Description,
161 StringRef GroupName,
162 StringRef GroupDescription, bool Enabled = true);
156163 };
157164
158165 /// The TimerGroup class is used to group together related timers into a single
161168 /// TimerGroup can be specified for a newly created timer in its constructor.
162169 class TimerGroup {
163170 std::string Name;
171 std::string Description;
164172 Timer *FirstTimer = nullptr; ///< First timer in the group.
165173 std::vector> TimersToPrint;
166174
170178 void operator=(const TimerGroup &TG) = delete;
171179
172180 public:
173 explicit TimerGroup(StringRef name);
181 explicit TimerGroup(StringRef Name, StringRef Description);
174182 ~TimerGroup();
175183
176 void setName(StringRef name) { Name.assign(name.begin(), name.end()); }
184 void setName(StringRef NewName, StringRef NewDescription) {
185 Name.assign(NewName.begin(), NewName.end());
186 Description.assign(NewDescription.begin(), NewDescription.end());
187 }
177188
178189 /// Print any started timers in this group and zero them.
179190 void print(raw_ostream &OS);
5454
5555 #define DEBUG_TYPE "asm-printer"
5656
57 static const char *const DWARFGroupName = "DWARF Emission";
58 static const char *const DbgTimerName = "Debug Info Emission";
59 static const char *const EHTimerName = "DWARF Exception Writer";
60 static const char *const CodeViewLineTablesGroupName = "CodeView Line Tables";
57 static const char *const DWARFGroupName = "dwarf";
58 static const char *const DWARFGroupDescription = "DWARF Emission";
59 static const char *const DbgTimerName = "emit";
60 static const char *const DbgTimerDescription = "Debug Info Emission";
61 static const char *const EHTimerName = "write_exception";
62 static const char *const EHTimerDescription = "DWARF Exception Writer";
63 static const char *const CodeViewLineTablesGroupName = "linetables";
64 static const char *const CodeViewLineTablesGroupDescription =
65 "CodeView Line Tables";
6166
6267 STATISTIC(EmittedInsts, "Number of machine instrs printed");
6368
243248 bool EmitCodeView = MMI->getModule()->getCodeViewFlag();
244249 if (EmitCodeView && TM.getTargetTriple().isKnownWindowsMSVCEnvironment()) {
245250 Handlers.push_back(HandlerInfo(new CodeViewDebug(this),
246 DbgTimerName,
247 CodeViewLineTablesGroupName));
251 DbgTimerName, DbgTimerDescription,
252 CodeViewLineTablesGroupName,
253 CodeViewLineTablesGroupDescription));
248254 }
249255 if (!EmitCodeView || MMI->getModule()->getDwarfVersion()) {
250256 DD = new DwarfDebug(this, &M);
251257 DD->beginModule();
252 Handlers.push_back(HandlerInfo(DD, DbgTimerName, DWARFGroupName));
258 Handlers.push_back(HandlerInfo(DD, DbgTimerName, DbgTimerDescription,
259 DWARFGroupName, DWARFGroupDescription));
253260 }
254261 }
255262
277284 break;
278285 }
279286 if (ES)
280 Handlers.push_back(HandlerInfo(ES, EHTimerName, DWARFGroupName));
287 Handlers.push_back(HandlerInfo(ES, EHTimerName, EHTimerDescription,
288 DWARFGroupName, DWARFGroupDescription));
281289 return false;
282290 }
283291
398406 unsigned AlignLog = getGVAlignmentLog2(GV, DL);
399407
400408 for (const HandlerInfo &HI : Handlers) {
401 NamedRegionTimer T(HI.TimerName, HI.TimerGroupName, TimePassesIsEnabled);
409 NamedRegionTimer T(HI.TimerName, HI.TimerDescription,
410 HI.TimerGroupName, HI.TimerGroupDescription,
411 TimePassesIsEnabled);
402412 HI.Handler->setSymbolSize(GVSym, Size);
403413 }
404414
587597
588598 // Emit pre-function debug and/or EH information.
589599 for (const HandlerInfo &HI : Handlers) {
590 NamedRegionTimer T(HI.TimerName, HI.TimerGroupName, TimePassesIsEnabled);
600 NamedRegionTimer T(HI.TimerName, HI.TimerDescription, HI.TimerGroupName,
601 HI.TimerGroupDescription, TimePassesIsEnabled);
591602 HI.Handler->beginFunction(MF);
592603 }
593604
851862
852863 if (ShouldPrintDebugScopes) {
853864 for (const HandlerInfo &HI : Handlers) {
854 NamedRegionTimer T(HI.TimerName, HI.TimerGroupName,
865 NamedRegionTimer T(HI.TimerName, HI.TimerDescription,
866 HI.TimerGroupName, HI.TimerGroupDescription,
855867 TimePassesIsEnabled);
856868 HI.Handler->beginInstruction(&MI);
857869 }
895907
896908 if (ShouldPrintDebugScopes) {
897909 for (const HandlerInfo &HI : Handlers) {
898 NamedRegionTimer T(HI.TimerName, HI.TimerGroupName,
910 NamedRegionTimer T(HI.TimerName, HI.TimerDescription,
911 HI.TimerGroupName, HI.TimerGroupDescription,
899912 TimePassesIsEnabled);
900913 HI.Handler->endInstruction();
901914 }
953966 }
954967
955968 for (const HandlerInfo &HI : Handlers) {
956 NamedRegionTimer T(HI.TimerName, HI.TimerGroupName, TimePassesIsEnabled);
969 NamedRegionTimer T(HI.TimerName, HI.TimerDescription, HI.TimerGroupName,
970 HI.TimerGroupDescription, TimePassesIsEnabled);
957971 HI.Handler->markFunctionEnd();
958972 }
959973
962976
963977 // Emit post-function debug and/or EH information.
964978 for (const HandlerInfo &HI : Handlers) {
965 NamedRegionTimer T(HI.TimerName, HI.TimerGroupName, TimePassesIsEnabled);
979 NamedRegionTimer T(HI.TimerName, HI.TimerDescription, HI.TimerGroupName,
980 HI.TimerGroupDescription, TimePassesIsEnabled);
966981 HI.Handler->endFunction(MF);
967982 }
968983 MMI->EndFunction();
11531168
11541169 // Finalize debug and EH information.
11551170 for (const HandlerInfo &HI : Handlers) {
1156 NamedRegionTimer T(HI.TimerName, HI.TimerGroupName,
1157 TimePassesIsEnabled);
1171 NamedRegionTimer T(HI.TimerName, HI.TimerDescription, HI.TimerGroupName,
1172 HI.TimerGroupDescription, TimePassesIsEnabled);
11581173 HI.Handler->endModule();
11591174 delete HI.Handler;
11601175 }
119119 "Abstract subprograms")),
120120 cl::init(DefaultLinkageNames));
121121
122 static const char *const DWARFGroupName = "DWARF Emission";
123 static const char *const DbgTimerName = "DWARF Debug Writer";
122 static const char *const DWARFGroupName = "dwarf";
123 static const char *const DWARFGroupDescription = "DWARF Emission";
124 static const char *const DbgTimerName = "writer";
125 static const char *const DbgTimerDescription = "DWARF Debug Writer";
124126
125127 void DebugLocDwarfExpression::EmitOp(uint8_t Op, const char *Comment) {
126128 BS.EmitInt8(
463465 // global DIEs and emit initial debug info sections. This is invoked by
464466 // the target AsmPrinter.
465467 void DwarfDebug::beginModule() {
466 NamedRegionTimer T(DbgTimerName, DWARFGroupName, TimePassesIsEnabled);
468 NamedRegionTimer T(DbgTimerName, DbgTimerDescription, DWARFGroupName,
469 DWARFGroupDescription, TimePassesIsEnabled);
467470 if (DisableDebugInfoPrinting)
468471 return;
469472
4040 VerifyRegAlloc("verify-regalloc", cl::location(RegAllocBase::VerifyEnabled),
4141 cl::desc("Verify during register allocation"));
4242
43 const char RegAllocBase::TimerGroupName[] = "Register Allocation";
43 const char RegAllocBase::TimerGroupName[] = "regalloc";
44 const char RegAllocBase::TimerGroupDescription[] = "Register Allocation";
4445 bool RegAllocBase::VerifyEnabled = false;
4546
4647 //===----------------------------------------------------------------------===//
6667 // register, unify them with the corresponding LiveIntervalUnion, otherwise push
6768 // them on the priority queue for later assignment.
6869 void RegAllocBase::seedLiveRegs() {
69 NamedRegionTimer T("Seed Live Regs", TimerGroupName, TimePassesIsEnabled);
70 NamedRegionTimer T("seed", "Seed Live Regs", TimerGroupName,
71 TimerGroupDescription, TimePassesIsEnabled);
7072 for (unsigned i = 0, e = MRI->getNumVirtRegs(); i != e; ++i) {
7173 unsigned Reg = TargetRegisterInfo::index2VirtReg(i);
7274 if (MRI->reg_nodbg_empty(Reg))
104104
105105 // Use this group name for NamedRegionTimer.
106106 static const char TimerGroupName[];
107 static const char TimerGroupDescription[];
107108
108109 /// Method called when the allocator is about to remove a LiveInterval.
109110 virtual void aboutToRemoveInterval(LiveInterval &LI) {}
868868 AllocationOrder &Order,
869869 SmallVectorImpl &NewVRegs,
870870 unsigned CostPerUseLimit) {
871 NamedRegionTimer T("Evict", TimerGroupName, TimePassesIsEnabled);
871 NamedRegionTimer T("evict", "Evict", TimerGroupName, TimerGroupDescription,
872 TimePassesIsEnabled);
872873
873874 // Keep track of the cheapest interference seen so far.
874875 EvictionCost BestCost;
19661967
19671968 // Local intervals are handled separately.
19681969 if (LIS->intervalIsInOneMBB(VirtReg)) {
1969 NamedRegionTimer T("Local Splitting", TimerGroupName, TimePassesIsEnabled);
1970 NamedRegionTimer T("local_split", "Local Splitting", TimerGroupName,
1971 TimerGroupDescription, TimePassesIsEnabled);
19701972 SA->analyze(&VirtReg);
19711973 unsigned PhysReg = tryLocalSplit(VirtReg, Order, NewVRegs);
19721974 if (PhysReg || !NewVRegs.empty())
19741976 return tryInstructionSplit(VirtReg, Order, NewVRegs);
19751977 }
19761978
1977 NamedRegionTimer T("Global Splitting", TimerGroupName, TimePassesIsEnabled);
1979 NamedRegionTimer T("global_split", "Global Splitting", TimerGroupName,
1980 TimerGroupDescription, TimePassesIsEnabled);
19781981
19791982 SA->analyze(&VirtReg);
19801983
25922595 DEBUG(dbgs() << "Do as if this register is in memory\n");
25932596 NewVRegs.push_back(VirtReg.reg);
25942597 } else {
2595 NamedRegionTimer T("Spiller", TimerGroupName, TimePassesIsEnabled);
2598 NamedRegionTimer T("spill", "Spiller", TimerGroupName,
2599 TimerGroupDescription, TimePassesIsEnabled);
25962600 LiveRangeEdit LRE(&VirtReg, NewVRegs, *MF, *LIS, VRM, this, &DeadRemats);
25972601 spiller().spill(LRE);
25982602 setStage(NewVRegs.begin(), NewVRegs.end(), RS_Done);
724724 }
725725
726726 void SelectionDAGISel::CodeGenAndEmitDAG() {
727 std::string GroupName;
728 if (TimePassesIsEnabled)
729 GroupName = "Instruction Selection and Scheduling";
727 StringRef GroupName = "sdag";
728 StringRef GroupDescription = "Instruction Selection and Scheduling";
730729 std::string BlockName;
731730 int BlockNumber = -1;
732731 (void)BlockNumber;
754753
755754 // Run the DAG combiner in pre-legalize mode.
756755 {
757 NamedRegionTimer T("DAG Combining 1", GroupName, TimePassesIsEnabled);
756 NamedRegionTimer T("combine1", "DAG Combining 1", GroupName,
757 GroupDescription, TimePassesIsEnabled);
758758 CurDAG->Combine(BeforeLegalizeTypes, *AA, OptLevel);
759759 }
760760
768768
769769 bool Changed;
770770 {
771 NamedRegionTimer T("Type Legalization", GroupName, TimePassesIsEnabled);
771 NamedRegionTimer T("legalize_types", "Type Legalization", GroupName,
772 GroupDescription, TimePassesIsEnabled);
772773 Changed = CurDAG->LegalizeTypes();
773774 }
774775
783784
784785 // Run the DAG combiner in post-type-legalize mode.
785786 {
786 NamedRegionTimer T("DAG Combining after legalize types", GroupName,
787 TimePassesIsEnabled);
787 NamedRegionTimer T("combine_lt", "DAG Combining after legalize types",
788 GroupName, GroupDescription, TimePassesIsEnabled);
788789 CurDAG->Combine(AfterLegalizeTypes, *AA, OptLevel);
789790 }
790791
794795 }
795796
796797 {
797 NamedRegionTimer T("Vector Legalization", GroupName, TimePassesIsEnabled);
798 NamedRegionTimer T("legalize_vec", "Vector Legalization", GroupName,
799 GroupDescription, TimePassesIsEnabled);
798800 Changed = CurDAG->LegalizeVectors();
799801 }
800802
801803 if (Changed) {
802804 {
803 NamedRegionTimer T("Type Legalization 2", GroupName, TimePassesIsEnabled);
805 NamedRegionTimer T("legalize_types2", "Type Legalization 2", GroupName,
806 GroupDescription, TimePassesIsEnabled);
804807 CurDAG->LegalizeTypes();
805808 }
806809
809812
810813 // Run the DAG combiner in post-type-legalize mode.
811814 {
812 NamedRegionTimer T("DAG Combining after legalize vectors", GroupName,
813 TimePassesIsEnabled);
815 NamedRegionTimer T("combine_lv", "DAG Combining after legalize vectors",
816 GroupName, GroupDescription, TimePassesIsEnabled);
814817 CurDAG->Combine(AfterLegalizeVectorOps, *AA, OptLevel);
815818 }
816819
822825 CurDAG->viewGraph("legalize input for " + BlockName);
823826
824827 {
825 NamedRegionTimer T("DAG Legalization", GroupName, TimePassesIsEnabled);
828 NamedRegionTimer T("legalize", "DAG Legalization", GroupName,
829 GroupDescription, TimePassesIsEnabled);
826830 CurDAG->Legalize();
827831 }
828832
834838
835839 // Run the DAG combiner in post-legalize mode.
836840 {
837 NamedRegionTimer T("DAG Combining 2", GroupName, TimePassesIsEnabled);
841 NamedRegionTimer T("combine2", "DAG Combining 2", GroupName,
842 GroupDescription, TimePassesIsEnabled);
838843 CurDAG->Combine(AfterLegalizeDAG, *AA, OptLevel);
839844 }
840845
850855 // Third, instruction select all of the operations to machine code, adding the
851856 // code to the MachineBasicBlock.
852857 {
853 NamedRegionTimer T("Instruction Selection", GroupName, TimePassesIsEnabled);
858 NamedRegionTimer T("isel", "Instruction Selection", GroupName,
859 GroupDescription, TimePassesIsEnabled);
854860 DoInstructionSelection();
855861 }
856862
863869 // Schedule machine code.
864870 ScheduleDAGSDNodes *Scheduler = CreateScheduler();
865871 {
866 NamedRegionTimer T("Instruction Scheduling", GroupName,
867 TimePassesIsEnabled);
872 NamedRegionTimer T("sched", "Instruction Scheduling", GroupName,
873 GroupDescription, TimePassesIsEnabled);
868874 Scheduler->Run(CurDAG, FuncInfo->MBB);
869875 }
870876
875881 // inserted into.
876882 MachineBasicBlock *FirstMBB = FuncInfo->MBB, *LastMBB;
877883 {
878 NamedRegionTimer T("Instruction Creation", GroupName, TimePassesIsEnabled);
884 NamedRegionTimer T("emit", "Instruction Creation", GroupName,
885 GroupDescription, TimePassesIsEnabled);
879886
880887 // FuncInfo->InsertPt is passed by reference and set to the end of the
881888 // scheduled instructions.
889896
890897 // Free the scheduler state.
891898 {
892 NamedRegionTimer T("Instruction Scheduling Cleanup", GroupName,
893 TimePassesIsEnabled);
899 NamedRegionTimer T("cleanup", "Instruction Scheduling Cleanup", GroupName,
900 GroupDescription, TimePassesIsEnabled);
894901 delete Scheduler;
895902 }
896903
448448 TimerGroup TG;
449449 public:
450450 // Use 'create' member to get this.
451 TimingInfo() : TG("... Pass execution timing report ...") {}
451 TimingInfo() : TG("pass", "... Pass execution timing report ...") {}
452452
453453 // TimingDtor - Print out information about timing information
454454 ~TimingInfo() {
471471
472472 sys::SmartScopedLock Lock(*TimingInfoMutex);
473473 Timer *&T = TimingData[P];
474 if (!T)
475 T = new Timer(P->getPassName(), TG);
474 if (!T) {
475 StringRef PassName = P->getPassName();
476 T = new Timer(PassName, PassName, TG);
477 }
476478 return T;
477479 }
478480 };
2525 extern bool TimePassesIsEnabled;
2626 }
2727
28 static const char *const TimeIRParsingGroupName = "LLVM IR Parsing";
29 static const char *const TimeIRParsingName = "Parse IR";
28 static const char *const TimeIRParsingGroupName = "irparse";
29 static const char *const TimeIRParsingGroupDescription = "LLVM IR Parsing";
30 static const char *const TimeIRParsingName = "parse";
31 static const char *const TimeIRParsingDescription = "Parse IR";
3032
3133 static std::unique_ptr
3234 getLazyIRModule(std::unique_ptr Buffer, SMDiagnostic &Err,
6668
6769 std::unique_ptr llvm::parseIR(MemoryBufferRef Buffer, SMDiagnostic &Err,
6870 LLVMContext &Context) {
69 NamedRegionTimer T(TimeIRParsingName, TimeIRParsingGroupName,
71 NamedRegionTimer T(TimeIRParsingName, TimeIRParsingDescription,
72 TimeIRParsingGroupName, TimeIRParsingGroupDescription,
7073 TimePassesIsEnabled);
7174 if (isBitcode((const unsigned char *)Buffer.getBufferStart(),
7275 (const unsigned char *)Buffer.getBufferEnd())) {
8080 sys::SmartScopedLock Lock(*TimerLock);
8181 tmp = DefaultTimerGroup;
8282 if (!tmp) {
83 tmp = new TimerGroup("Miscellaneous Ungrouped Timers");
83 tmp = new TimerGroup("misc", "Miscellaneous Ungrouped Timers");
8484 sys::MemoryFence();
8585 DefaultTimerGroup = tmp;
8686 }
9292 // Timer Implementation
9393 //===----------------------------------------------------------------------===//
9494
95 void Timer::init(StringRef N) {
96 init(N, *getDefaultTimerGroup());
97 }
98
99 void Timer::init(StringRef N, TimerGroup &tg) {
95 void Timer::init(StringRef Name, StringRef Description) {
96 init(Name, Description, *getDefaultTimerGroup());
97 }
98
99 void Timer::init(StringRef Name, StringRef Description, TimerGroup &tg) {
100100 assert(!TG && "Timer already initialized");
101 Name.assign(N.begin(), N.end());
101 this->Name.assign(Name.begin(), Name.end());
102 this->Description.assign(Description.begin(), Description.end());
102103 Running = Triggered = false;
103104 TG = &tg;
104105 TG->addTimer(*this);
192193 delete I->second.first;
193194 }
194195
195 Timer &get(StringRef Name, StringRef GroupName) {
196 Timer &get(StringRef Name, StringRef Description, StringRef GroupName,
197 StringRef GroupDescription) {
196198 sys::SmartScopedLock L(*TimerLock);
197199
198200 std::pair &GroupEntry = Map[GroupName];
199201
200202 if (!GroupEntry.first)
201 GroupEntry.first = new TimerGroup(GroupName);
203 GroupEntry.first = new TimerGroup(GroupName, GroupDescription);
202204
203205 Timer &T = GroupEntry.second[Name];
204206 if (!T.isInitialized())
205 T.init(Name, *GroupEntry.first);
207 T.init(Name, Description, *GroupEntry.first);
206208 return T;
207209 }
208210 };
211213
212214 static ManagedStatic NamedGroupedTimers;
213215
214 NamedRegionTimer::NamedRegionTimer(StringRef Name, StringRef GroupName,
215 bool Enabled)
216 : TimeRegion(!Enabled ? nullptr : &NamedGroupedTimers->get(Name, GroupName)){}
216 NamedRegionTimer::NamedRegionTimer(StringRef Name, StringRef Description,
217 StringRef GroupName,
218 StringRef GroupDescription, bool Enabled)
219 : TimeRegion(!Enabled ? nullptr
220 : &NamedGroupedTimers->get(Name, Description, GroupName,
221 GroupDescription)) {}
217222
218223 //===----------------------------------------------------------------------===//
219224 // TimerGroup Implementation
223228 /// ctor/dtor and is protected by the TimerLock lock.
224229 static TimerGroup *TimerGroupList = nullptr;
225230
226 TimerGroup::TimerGroup(StringRef name)
227 : Name(name.begin(), name.end()) {
228
231 TimerGroup::TimerGroup(StringRef Name, StringRef Description)
232 : Name(Name.begin(), Name.end()),
233 Description(Description.begin(), Description.end()) {
229234 // Add the group to TimerGroupList.
230235 sys::SmartScopedLock L(*TimerLock);
231236 if (TimerGroupList)
254259
255260 // If the timer was started, move its data to TimersToPrint.
256261 if (T.hasTriggered())
257 TimersToPrint.emplace_back(T.Time, T.Name);
262 TimersToPrint.emplace_back(T.Time, T.Description);
258263
259264 T.TG = nullptr;
260265
294299 // Print out timing header.
295300 OS << "===" << std::string(73, '-') << "===\n";
296301 // Figure out how many spaces to indent TimerGroup name.
297 unsigned Padding = (80-Name.length())/2;
302 unsigned Padding = (80-Description.length())/2;
298303 if (Padding > 80) Padding = 0; // Don't allow "negative" numbers
299 OS.indent(Padding) << Name << '\n';
304 OS.indent(Padding) << Description << '\n';
300305 OS << "===" << std::string(73, '-') << "===\n";
301306
302307 // If this is not an collection of ungrouped times, print the total time.
339344 // reset them.
340345 for (Timer *T = FirstTimer; T; T = T->Next) {
341346 if (!T->hasTriggered()) continue;
342 TimersToPrint.emplace_back(T->Time, T->Name);
347 TimersToPrint.emplace_back(T->Time, T->Description);
343348
344349 // Clear out the time.
345350 T->clear();
15181518 MachineBasicBlock *RootB = MDT->getRoot();
15191519 OrderedRegisterList AvailR(CellOrd);
15201520
1521 const char *const TGName = "hexinsert";
1522 const char *const TGDesc = "Generate Insert Instructions";
1523
15211524 {
1522 NamedRegionTimer _T("collection", "hexinsert", TimingDetail);
1525 NamedRegionTimer _T("collection", "collection", TGName, TGDesc,
1526 TimingDetail);
15231527 collectInBlock(RootB, AvailR);
15241528 // Complete the information gathered in IFMap.
15251529 computeRemovableRegisters();
15341538 return Changed;
15351539
15361540 {
1537 NamedRegionTimer _T("pruning", "hexinsert", TimingDetail);
1541 NamedRegionTimer _T("pruning", "pruning", TGName, TGDesc, TimingDetail);
15381542 pruneCandidates();
15391543 }
15401544
15471551 return Changed;
15481552
15491553 {
1550 NamedRegionTimer _T("selection", "hexinsert", TimingDetail);
1554 NamedRegionTimer _T("selection", "selection", TGName, TGDesc, TimingDetail);
15511555 selectCandidates();
15521556 }
15531557
15731577 return Changed;
15741578
15751579 {
1576 NamedRegionTimer _T("generation", "hexinsert", TimingDetail);
1580 NamedRegionTimer _T("generation", "generation", TGName, TGDesc,
1581 TimingDetail);
15771582 generateInserts();
15781583 }
15791584
752752 DataFlowGraph::DataFlowGraph(MachineFunction &mf, const TargetInstrInfo &tii,
753753 const TargetRegisterInfo &tri, const MachineDominatorTree &mdt,
754754 const MachineDominanceFrontier &mdf, const TargetOperandInfo &toi)
755 : TimeG("rdf"), LMI(), MF(mf), TII(tii), TRI(tri), MDT(mdt), MDF(mdf),
756 TOI(toi) {
755 : LMI(), MF(mf), TII(tii), TRI(tri), MDT(mdt), MDF(mdf), TOI(toi) {
757756 }
758757
759758
910910 return BlockNodes[BB];
911911 }
912912
913 TimerGroup TimeG;
914913 NodeAddr Func;
915914 NodeAllocator Memory;
916915 // Local map: MachineBasicBlock -> NodeAddr
3232 }
3333
3434 TEST(Timer, Additivity) {
35 Timer T1("T1");
35 Timer T1("T1", "T1");
3636
3737 EXPECT_TRUE(T1.isInitialized());
3838
4949 }
5050
5151 TEST(Timer, CheckIfTriggered) {
52 Timer T1("T1");
52 Timer T1("T1", "T1");
5353
5454 EXPECT_FALSE(T1.hasTriggered());
5555 T1.startTimer();
142142 }
143143 }
144144
145 static void benchmark( llvm::TimerGroup &Group
146 , llvm::StringRef Name
147 , llvm::StringRef JSONText) {
148 llvm::Timer BaseLine((Name + ": Loop").str(), Group);
145 static void benchmark(llvm::TimerGroup &Group, llvm::StringRef Name,
146 llvm::StringRef Description, llvm::StringRef JSONText) {
147 llvm::Timer BaseLine((Name + ".loop").str(), (Description + ": Loop").str(),
148 Group);
149149 BaseLine.startTimer();
150150 char C = 0;
151151 for (llvm::StringRef::iterator I = JSONText.begin(),
154154 BaseLine.stopTimer();
155155 volatile char DontOptimizeOut = C; (void)DontOptimizeOut;
156156
157 llvm::Timer Tokenizing((Name + ": Tokenizing").str(), Group);
157 llvm::Timer Tokenizing((Name + ".tokenizing").str(),
158 (Description + ": Tokenizing").str(), Group);
158159 Tokenizing.startTimer();
159160 {
160161 yaml::scanTokens(JSONText);
161162 }
162163 Tokenizing.stopTimer();
163164
164 llvm::Timer Parsing((Name + ": Parsing").str(), Group);
165 llvm::Timer Parsing((Name + ".parsing").str(),
166 (Description + ": Parsing").str(), Group);
165167 Parsing.startTimer();
166168 {
167169 llvm::SourceMgr SM;
217219 }
218220
219221 if (Verify) {
220 llvm::TimerGroup Group("YAML parser benchmark");
221 benchmark(Group, "Fast", createJSONText(10, 500));
222 llvm::TimerGroup Group("yaml", "YAML parser benchmark");
223 benchmark(Group, "Fast", "Fast", createJSONText(10, 500));
222224 } else if (!DumpCanonical && !DumpTokens) {
223 llvm::TimerGroup Group("YAML parser benchmark");
224 benchmark(Group, "Small Values", createJSONText(MemoryLimitMB, 5));
225 benchmark(Group, "Medium Values", createJSONText(MemoryLimitMB, 500));
226 benchmark(Group, "Large Values", createJSONText(MemoryLimitMB, 50000));
225 llvm::TimerGroup Group("yaml", "YAML parser benchmark");
226 benchmark(Group, "Small", "Small Values", createJSONText(MemoryLimitMB, 5));
227 benchmark(Group, "Medium", "Medium Values",
228 createJSONText(MemoryLimitMB, 500));
229 benchmark(Group, "Large", "Large Values",
230 createJSONText(MemoryLimitMB, 50000));
227231 }
228232
229233 return 0;