@@ -63,16 +63,9 @@ class PassTimingInfo {
63
63
private:
64
64
StringMap<unsigned > PassIDCountMap; // /< Map that counts instances of passes
65
65
DenseMap<PassInstanceID, std::unique_ptr<Timer>> TimingData; // /< timers for pass instances
66
- TimerGroup TG ;
66
+ TimerGroup *PassTG = nullptr ;
67
67
68
68
public:
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
-
76
69
// / Initializes the static \p TheTimeInfo member to a non-null value when
77
70
// / -time-passes is enabled. Leaves it null otherwise.
78
71
// /
@@ -94,14 +87,6 @@ class PassTimingInfo {
94
87
95
88
static ManagedStatic<sys::SmartMutex<true >> TimingInfoMutex;
96
89
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
-
105
90
void PassTimingInfo::init () {
106
91
if (TheTimeInfo || !TimePassesIsEnabled)
107
92
return ;
@@ -110,12 +95,16 @@ void PassTimingInfo::init() {
110
95
// This guarantees that the object will be constructed after static globals,
111
96
// thus it will be destroyed before them.
112
97
static ManagedStatic<PassTimingInfo> TTI;
98
+ if (!TTI->PassTG )
99
+ TTI->PassTG = &NamedRegionTimer::getNamedTimerGroup (
100
+ TimePassesHandler::PassGroupName, TimePassesHandler::PassGroupDesc);
113
101
TheTimeInfo = &*TTI;
114
102
}
115
103
116
104
// / Prints out timing information and then resets the timers.
117
105
void 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 );
119
108
}
120
109
121
110
Timer *PassTimingInfo::newPassTimer (StringRef PassID, StringRef PassDesc) {
@@ -124,7 +113,8 @@ Timer *PassTimingInfo::newPassTimer(StringRef PassID, StringRef PassDesc) {
124
113
// Appending description with a pass-instance number for all but the first one
125
114
std::string PassDescNumbered =
126
115
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);
128
118
}
129
119
130
120
Timer *PassTimingInfo::getPassTimer (Pass *P, PassInstanceID Pass) {
@@ -193,9 +183,7 @@ Timer &TimePassesHandler::getPassTimer(StringRef PassID, bool IsPass) {
193
183
}
194
184
195
185
TimePassesHandler::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) {}
199
187
200
188
TimePassesHandler::TimePassesHandler ()
201
189
: TimePassesHandler(TimePassesIsEnabled, TimePassesPerRun) {}
0 commit comments