Lines Matching +full:one +full:- +full:timer +full:- +full:only
1 //===- PassTimingInfo.cpp - LLVM Pass Timing Implementation ---------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
12 // PassTimingInfo Class - This class is used to calculate information about the
13 // amount of time each pass takes to execute. This only happens when
14 // -time-passes is enabled on the command line.
16 //===----------------------------------------------------------------------===//
33 #define DEBUG_TYPE "time-passes"
41 "time-passes", cl::location(TimePassesIsEnabled), cl::Hidden,
45 "time-passes-per-run", cl::location(TimePassesPerRun), cl::Hidden,
52 //===----------------------------------------------------------------------===//
58 /// interfaces completely. This is now exclusively for legacy-pass-manager use.
65 DenseMap<PassInstanceID, std::unique_ptr<Timer>> TimingData; ///< timers for pass instances
69 /// Default constructor for yet-inactive timeinfo.
76 /// Initializes the static \p TheTimeInfo member to a non-null value when
77 /// -time-passes is enabled. Leaves it null otherwise.
86 /// Returns the timer for the specified pass if it exists.
87 Timer *getPassTimer(Pass *, PassInstanceID);
92 Timer *newPassTimer(StringRef PassID, StringRef PassDesc);
109 // Constructed the first time this is called, iff -time-passes is enabled.
121 Timer *PassTimingInfo::newPassTimer(StringRef PassID, StringRef PassDesc) {
124 // Appending description with a pass-instance number for all but the first one
127 return new Timer(PassID, PassDescNumbered, TG);
130 Timer *PassTimingInfo::getPassTimer(Pass *P, PassInstanceID Pass) {
131 if (P->getAsPMDataManager())
136 std::unique_ptr<Timer> &T = TimingData[Pass];
139 StringRef PassName = P->getPassName();
141 if (const PassInfo *PI = Pass::lookupPassInfo(P->getPassID()))
142 PassArgument = PI->getPassArgument();
152 Timer *getPassTimer(Pass *P) {
155 return legacy::PassTimingInfo::TheTimeInfo->getPassTimer(P, P);
163 legacy::PassTimingInfo::TheTimeInfo->print(OutStream);
166 //===----------------------------------------------------------------------===//
168 //===----------------------------------------------------------------------===//
170 /// Returns the timer for the specified pass invocation of \p PassID.
171 /// Each time it creates a new timer.
172 Timer &TimePassesHandler::getPassTimer(StringRef PassID, bool IsPass) {
177 Timers.emplace_back(new Timer(PassID, PassID, TG));
182 // one more timer to it.
188 Timer *T = new Timer(PassID, FullDesc, TG);
229 const Timer* MyTimer = MyTimers[idx].get();
230 if (MyTimer && MyTimer->isRunning())
239 const Timer* MyTimer = MyTimers[idx].get();
240 if (MyTimer && MyTimer->hasTriggered() && !MyTimer->isRunning())
255 // Stop the previous pass timer to prevent double counting when a
258 assert(PassActiveTimerStack.back()->isRunning());
259 PassActiveTimerStack.back()->stopTimer();
261 Timer &MyTimer = getPassTimer(PassID, /*IsPass*/ true);
271 Timer *MyTimer = PassActiveTimerStack.pop_back_val();
272 assert(MyTimer && "timer should be present");
273 assert(MyTimer->isRunning());
274 MyTimer->stopTimer();
276 // Restart the previously stopped timer.
278 assert(!PassActiveTimerStack.back()->isRunning());
279 PassActiveTimerStack.back()->startTimer();
284 // Stop the previous analysis timer to prevent double counting when an
287 assert(AnalysisActiveTimerStack.back()->isRunning());
288 AnalysisActiveTimerStack.back()->stopTimer();
291 Timer &MyTimer = getPassTimer(PassID, /*IsPass*/ false);
299 Timer *MyTimer = AnalysisActiveTimerStack.pop_back_val();
300 assert(MyTimer && "timer should be present");
301 if (MyTimer->isRunning())
302 MyTimer->stopTimer();
304 // Restart the previously stopped timer.
306 assert(!AnalysisActiveTimerStack.back()->isRunning());
307 AnalysisActiveTimerStack.back()->startTimer();
316 [this](StringRef P, Any) { this->startPassTimer(P); });
319 this->stopPassTimer(P);
323 this->stopPassTimer(P);
326 [this](StringRef P, Any) { this->startAnalysisTimer(P); });
328 [this](StringRef P, Any) { this->stopAnalysisTimer(P); });