Skip to content

Commit 7fcbfee

Browse files
committed
more code review comments
1 parent 6763fc3 commit 7fcbfee

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-17
lines changed

llvm/include/llvm/Support/Timer.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,6 @@ struct NamedRegionTimer : public TimeRegion {
170170
StringRef GroupName,
171171
StringRef GroupDescription, bool Enabled = true);
172172

173-
// Create or get a timer stored in the same global map as other timers owned
174-
// by NamedRegionTimer.
175-
static Timer &getNamedGroupTimer(StringRef Name, StringRef Description,
176-
StringRef GroupName,
177-
StringRef GroupDescription);
178-
179173
// Create or get a TimerGroup stored in the same global map owned by
180174
// NamedRegionTimer.
181175
static TimerGroup &getNamedTimerGroup(StringRef GroupName,

llvm/lib/IR/PassTimingInfo.cpp

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ class PassTimingInfo {
6363
private:
6464
StringMap<unsigned> PassIDCountMap; ///< Map that counts instances of passes
6565
DenseMap<PassInstanceID, Timer *> TimingData; ///< timers for pass instances
66+
TimerGroup *PassTG = nullptr;
6667

6768
public:
6869
PassTimingInfo() = default;
@@ -98,14 +99,16 @@ void PassTimingInfo::init() {
9899
// This guarantees that the object will be constructed after static globals,
99100
// thus it will be destroyed before them.
100101
static ManagedStatic<PassTimingInfo> TTI;
102+
if (!TTI->PassTG)
103+
TTI->PassTG = &NamedRegionTimer::getNamedTimerGroup(
104+
TimePassesHandler::PassGroupName, TimePassesHandler::PassGroupDesc);
101105
TheTimeInfo = &*TTI;
102106
}
103107

104108
/// Prints out timing information and then resets the timers.
105109
void PassTimingInfo::print(raw_ostream *OutStream) {
106-
NamedRegionTimer::getNamedTimerGroup(TimePassesHandler::PassGroupName,
107-
TimePassesHandler::PassGroupDesc)
108-
.print(OutStream ? *OutStream : *CreateInfoOutputFile(), true);
110+
assert(PassTG && "PassTG is null, did you call PassTimingInfo::Init()?");
111+
PassTG->print(OutStream ? *OutStream : *CreateInfoOutputFile(), true);
109112
}
110113

111114
Timer *PassTimingInfo::newPassTimer(StringRef PassID, StringRef PassDesc) {
@@ -114,10 +117,8 @@ Timer *PassTimingInfo::newPassTimer(StringRef PassID, StringRef PassDesc) {
114117
// Appending description with a pass-instance number for all but the first one
115118
std::string PassDescNumbered =
116119
num <= 1 ? PassDesc.str() : formatv("{0} #{1}", PassDesc, num).str();
117-
return new Timer(
118-
PassID, PassDescNumbered,
119-
NamedRegionTimer::getNamedTimerGroup(TimePassesHandler::PassGroupName,
120-
TimePassesHandler::PassGroupDesc));
120+
assert(PassTG && "PassTG is null, did you call PassTimingInfo::Init()?");
121+
return new Timer(PassID, PassDescNumbered, *PassTG);
121122
}
122123

123124
Timer *PassTimingInfo::getPassTimer(Pass *P, PassInstanceID Pass) {
@@ -207,10 +208,8 @@ void TimePassesHandler::print() {
207208
OS = &*MaybeCreated;
208209
}
209210

210-
NamedRegionTimer::getNamedTimerGroup(PassGroupName, PassGroupDesc)
211-
.print(*OS, true);
212-
NamedRegionTimer::getNamedTimerGroup(AnalysisGroupName, AnalysisGroupDesc)
213-
.print(*OS, true);
211+
PassTG.print(*OS, true);
212+
AnalysisTG.print(*OS, true);
214213
}
215214

216215
LLVM_DUMP_METHOD void TimePassesHandler::dump() const {

0 commit comments

Comments
 (0)