@@ -63,16 +63,9 @@ class PassTimingInfo {
6363private:
6464 StringMap<unsigned > PassIDCountMap; // /< Map that counts instances of passes
6565 DenseMap<PassInstanceID, std::unique_ptr<Timer>> TimingData; // /< timers for pass instances
66- TimerGroup TG ;
66+ TimerGroup *PassTG = nullptr ;
6767
6868public:
69- // / Default constructor for yet-inactive timeinfo.
70- // / Use \p init() to activate it.
71- PassTimingInfo ();
72-
73- // / Print out timing information and release timers.
74- ~PassTimingInfo ();
75-
7669 // / Initializes the static \p TheTimeInfo member to a non-null value when
7770 // / -time-passes is enabled. Leaves it null otherwise.
7871 // /
@@ -94,14 +87,6 @@ class PassTimingInfo {
9487
9588static ManagedStatic<sys::SmartMutex<true >> TimingInfoMutex;
9689
97- PassTimingInfo::PassTimingInfo () : TG(" pass" , " Pass execution timing report" ) {}
98-
99- PassTimingInfo::~PassTimingInfo () {
100- // Deleting the timers accumulates their info into the TG member.
101- // Then TG member is (implicitly) deleted, actually printing the report.
102- TimingData.clear ();
103- }
104-
10590void PassTimingInfo::init () {
10691 if (TheTimeInfo || !TimePassesIsEnabled)
10792 return ;
@@ -110,12 +95,16 @@ void PassTimingInfo::init() {
11095 // This guarantees that the object will be constructed after static globals,
11196 // thus it will be destroyed before them.
11297 static ManagedStatic<PassTimingInfo> TTI;
98+ if (!TTI->PassTG )
99+ TTI->PassTG = &NamedRegionTimer::getNamedTimerGroup (
100+ TimePassesHandler::PassGroupName, TimePassesHandler::PassGroupDesc);
113101 TheTimeInfo = &*TTI;
114102}
115103
116104// / Prints out timing information and then resets the timers.
117105void PassTimingInfo::print (raw_ostream *OutStream) {
118- TG.print (OutStream ? *OutStream : *CreateInfoOutputFile (), true );
106+ assert (PassTG && " PassTG is null, did you call PassTimingInfo::Init()?" );
107+ PassTG->print (OutStream ? *OutStream : *CreateInfoOutputFile (), true );
119108}
120109
121110Timer *PassTimingInfo::newPassTimer (StringRef PassID, StringRef PassDesc) {
@@ -124,7 +113,8 @@ Timer *PassTimingInfo::newPassTimer(StringRef PassID, StringRef PassDesc) {
124113 // Appending description with a pass-instance number for all but the first one
125114 std::string PassDescNumbered =
126115 num <= 1 ? PassDesc.str () : formatv (" {0} #{1}" , PassDesc, num).str ();
127- return new Timer (PassID, PassDescNumbered, TG);
116+ assert (PassTG && " PassTG is null, did you call PassTimingInfo::Init()?" );
117+ return new Timer (PassID, PassDescNumbered, *PassTG);
128118}
129119
130120Timer *PassTimingInfo::getPassTimer (Pass *P, PassInstanceID Pass) {
@@ -193,9 +183,7 @@ Timer &TimePassesHandler::getPassTimer(StringRef PassID, bool IsPass) {
193183}
194184
195185TimePassesHandler::TimePassesHandler (bool Enabled, bool PerRun)
196- : PassTG(" pass" , " Pass execution timing report" ),
197- AnalysisTG (" analysis" , " Analysis execution timing report" ),
198- Enabled(Enabled), PerRun(PerRun) {}
186+ : Enabled(Enabled), PerRun(PerRun) {}
199187
200188TimePassesHandler::TimePassesHandler ()
201189 : TimePassesHandler(TimePassesIsEnabled, TimePassesPerRun) {}
0 commit comments