Skip to content

Commit 2c8eb58

Browse files
committed
code review comments
1 parent b2b4d52 commit 2c8eb58

File tree

4 files changed

+28
-31
lines changed

4 files changed

+28
-31
lines changed

llvm/include/llvm/IR/PassTimingInfo.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,18 @@ class TimePassesHandler {
6565
bool Enabled;
6666
bool PerRun;
6767

68+
TimerGroup &PassTG =
69+
NamedRegionTimer::getNamedTimerGroup(PassGroupName, PassGroupDesc);
70+
TimerGroup &AnalysisTG = NamedRegionTimer::getNamedTimerGroup(
71+
AnalysisGroupName, AnalysisGroupDesc);
72+
6873
public:
74+
static constexpr StringRef PassGroupName = "pass";
75+
static constexpr StringRef AnalysisGroupName = "analysis";
76+
static constexpr StringRef PassGroupDesc = "Pass execution timing report";
77+
static constexpr StringRef AnalysisGroupDesc =
78+
"Analysis execution timing report";
79+
6980
TimePassesHandler();
7081
TimePassesHandler(bool Enabled, bool PerRun = false);
7182

llvm/include/llvm/Support/Timer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,8 @@ struct NamedRegionTimer : public TimeRegion {
178178

179179
// Create or get a TimerGroup stored in the same global map owned by
180180
// NamedRegionTimer.
181-
static TimerGroup &getNamedGroupTimerGroup(StringRef GroupName,
182-
StringRef GroupDescription);
181+
static TimerGroup &getNamedTimerGroup(StringRef GroupName,
182+
StringRef GroupDescription);
183183
};
184184

185185
/// The TimerGroup class is used to group together related timers into a single

llvm/lib/IR/PassTimingInfo.cpp

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,6 @@ namespace llvm {
3737
bool TimePassesIsEnabled = false;
3838
bool TimePassesPerRun = false;
3939

40-
static constexpr StringRef PassGroupName = "pass";
41-
static constexpr StringRef AnalysisGroupName = "analysis";
42-
static constexpr StringRef PassGroupDesc = "Pass execution timing report";
43-
static constexpr StringRef AnalysisGroupDesc =
44-
"Analysis execution timing report";
45-
4640
static cl::opt<bool, true> EnableTiming(
4741
"time-passes", cl::location(TimePassesIsEnabled), cl::Hidden,
4842
cl::desc("Time each pass, printing elapsed time for each on exit"));
@@ -109,7 +103,8 @@ void PassTimingInfo::init() {
109103

110104
/// Prints out timing information and then resets the timers.
111105
void PassTimingInfo::print(raw_ostream *OutStream) {
112-
NamedRegionTimer::getNamedGroupTimerGroup(PassGroupName, PassGroupDesc)
106+
NamedRegionTimer::getNamedTimerGroup(TimePassesHandler::PassGroupName,
107+
TimePassesHandler::PassGroupDesc)
113108
.print(OutStream ? *OutStream : *CreateInfoOutputFile(), true);
114109
}
115110

@@ -119,8 +114,10 @@ Timer *PassTimingInfo::newPassTimer(StringRef PassID, StringRef PassDesc) {
119114
// Appending description with a pass-instance number for all but the first one
120115
std::string PassDescNumbered =
121116
num <= 1 ? PassDesc.str() : formatv("{0} #{1}", PassDesc, num).str();
122-
return &NamedRegionTimer::getNamedGroupTimer(PassID, PassDescNumbered,
123-
PassGroupName, PassGroupDesc);
117+
return new Timer(
118+
PassID, PassDescNumbered,
119+
NamedRegionTimer::getNamedTimerGroup(TimePassesHandler::PassGroupName,
120+
TimePassesHandler::PassGroupDesc));
124121
}
125122

126123
Timer *PassTimingInfo::getPassTimer(Pass *P, PassInstanceID Pass) {
@@ -166,9 +163,7 @@ void reportAndResetTimings(raw_ostream *OutStream) {
166163
/// Returns the timer for the specified pass invocation of \p PassID.
167164
/// Each time it creates a new timer.
168165
Timer &TimePassesHandler::getPassTimer(StringRef PassID, bool IsPass) {
169-
StringRef TGName = IsPass ? PassGroupName : PassGroupDesc;
170-
StringRef TGDesc = IsPass ? PassGroupDesc : AnalysisGroupDesc;
171-
TimerGroup &TG = NamedRegionTimer::getNamedGroupTimerGroup(TGName, TGDesc);
166+
TimerGroup &TG = IsPass ? PassTG : AnalysisTG;
172167
if (!PerRun) {
173168
TimerVector &Timers = TimingData[PassID];
174169
if (Timers.size() == 0)
@@ -212,10 +207,9 @@ void TimePassesHandler::print() {
212207
OS = &*MaybeCreated;
213208
}
214209

215-
NamedRegionTimer::getNamedGroupTimerGroup(PassGroupName, PassGroupDesc)
210+
NamedRegionTimer::getNamedTimerGroup(PassGroupName, PassGroupDesc)
216211
.print(*OS, true);
217-
NamedRegionTimer::getNamedGroupTimerGroup(AnalysisGroupName,
218-
AnalysisGroupDesc)
212+
NamedRegionTimer::getNamedTimerGroup(AnalysisGroupName, AnalysisGroupDesc)
219213
.print(*OS, true);
220214
}
221215

llvm/lib/Support/Timer.cpp

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -250,21 +250,13 @@ class Name2PairMap {
250250
NamedRegionTimer::NamedRegionTimer(StringRef Name, StringRef Description,
251251
StringRef GroupName,
252252
StringRef GroupDescription, bool Enabled)
253-
: TimeRegion(!Enabled ? nullptr
254-
: &getNamedGroupTimer(Name, Description, GroupName,
255-
GroupDescription)) {}
253+
: TimeRegion(!Enabled
254+
? nullptr
255+
: &namedGroupedTimers().get(Name, Description, GroupName,
256+
GroupDescription)) {}
256257

257-
Timer &NamedRegionTimer::getNamedGroupTimer(StringRef Name,
258-
StringRef Description,
259-
StringRef GroupName,
260-
StringRef GroupDescription) {
261-
return namedGroupedTimers().get(Name, Description, GroupName,
262-
GroupDescription);
263-
}
264-
265-
TimerGroup &
266-
NamedRegionTimer::getNamedGroupTimerGroup(StringRef GroupName,
267-
StringRef GroupDescription) {
258+
TimerGroup &NamedRegionTimer::getNamedTimerGroup(StringRef GroupName,
259+
StringRef GroupDescription) {
268260
return namedGroupedTimers().getTimerGroup(GroupName, GroupDescription);
269261
}
270262

0 commit comments

Comments
 (0)