Go to the documentation of this file.
33 #define DEBUG_TYPE "time-passes"
42 cl::desc(
"Time each pass, printing elapsed time for each on exit"));
46 cl::desc(
"Time each pass run, printing elapsed time for each run on exit"),
59 class PassTimingInfo {
61 using PassInstanceID =
void *;
89 static PassTimingInfo *TheTimeInfo;
97 PassTimingInfo::PassTimingInfo()
98 : TG(
"pass",
"... Pass execution timing report ...") {}
100 PassTimingInfo::~PassTimingInfo() {
123 unsigned &num = PassIDCountMap[PassID];
126 std::string PassDescNumbered =
127 num <= 1 ? PassDesc.
str() :
formatv(
"{0} #{1}", PassDesc, num).str();
128 return new Timer(PassID, PassDescNumbered, TG);
132 if (
P->getAsPMDataManager())
137 std::unique_ptr<Timer> &
T = TimingData[
Pass];
142 if (
const PassInfo *PI = Pass::lookupPassInfo(
P->getPassID()))
143 PassArgument = PI->getPassArgument();
149 PassTimingInfo *PassTimingInfo::TheTimeInfo;
155 if (legacy::PassTimingInfo::TheTimeInfo)
156 return legacy::PassTimingInfo::TheTimeInfo->getPassTimer(
P,
P);
163 if (legacy::PassTimingInfo::TheTimeInfo)
164 legacy::PassTimingInfo::TheTimeInfo->print(OutStream);
175 TimerVector &Timers = TimingData[PassID];
176 if (Timers.size() == 0)
177 Timers.emplace_back(
new Timer(PassID, PassID, TG));
178 return *Timers.front();
183 TimerVector &Timers = TimingData[PassID];
184 unsigned Count = Timers.size() + 1;
186 std::string FullDesc =
formatv(
"{0} #{1}", PassID, Count).str();
189 Timers.emplace_back(
T);
190 assert(Count == Timers.size() &&
"Timers vector not adjusted correctly.");
196 : TG(
"pass",
"... Pass execution timing report ..."),
Enabled(
Enabled),
213 dbgs() <<
"Dumping timers for " << getTypeName<TimePassesHandler>()
214 <<
":\n\tRunning:\n";
215 for (
auto &
I : TimingData) {
217 const TimerVector& MyTimers =
I.getValue();
218 for (
unsigned idx = 0; idx < MyTimers.size(); idx++) {
219 const Timer* MyTimer = MyTimers[idx].get();
221 dbgs() <<
"\tTimer " << MyTimer <<
" for pass " << PassID <<
"(" << idx <<
")\n";
224 dbgs() <<
"\tTriggered:\n";
225 for (
auto &
I : TimingData) {
227 const TimerVector& MyTimers =
I.getValue();
228 for (
unsigned idx = 0; idx < MyTimers.size(); idx++) {
229 const Timer* MyTimer = MyTimers[idx].get();
231 dbgs() <<
"\tTimer " << MyTimer <<
" for pass " << PassID <<
"(" << idx <<
")\n";
236 void TimePassesHandler::startTimer(
StringRef PassID) {
237 Timer &MyTimer = getPassTimer(PassID);
238 TimerStack.push_back(&MyTimer);
243 void TimePassesHandler::stopTimer(
StringRef PassID) {
244 assert(TimerStack.size() > 0 &&
"empty stack in popTimer");
245 Timer *MyTimer = TimerStack.pop_back_val();
246 assert(MyTimer &&
"timer should be present");
251 void TimePassesHandler::runBeforePass(
StringRef PassID) {
253 {
"PassManager",
"PassAdaptor",
"AnalysisManagerProxy"}))
262 void TimePassesHandler::runAfterPass(
StringRef PassID) {
264 {
"PassManager",
"PassAdaptor",
"AnalysisManagerProxy"}))
281 this->runAfterPass(
P);
285 this->runAfterPass(
P);
A set of analyses that are preserved following a run of a transformation pass.
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
This is an optimization pass for GlobalISel generic memory operations.
void reportAndResetTimings(raw_ostream *OutStream=nullptr)
If -time-passes has been specified, report the timings immediately and then reset the timers to zero.
print lazy value Lazy Value Info Printer Pass
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
bool hasTriggered() const
Check if startTimer() has ever been called on this timer.
LocationClass< Ty > location(Ty &L)
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
void registerBeforeNonSkippedPassCallback(CallableT C)
void print(raw_ostream &OS, bool ResetAfterPrint=false)
Print any started timers in this group, optionally resetting timers after printing them.
This class is used to track the amount of time spent between invocations of its startTimer()/stopTime...
bool TimePassesIsEnabled
If the user specifies the -time-passes argument on an LLVM tool command line then the value of this b...
PassInstrumentationCallbacks PIC
PassInfo class - An instance of this class exists for every pass known by the system,...
void startTimer()
Start the timer running.
std::unique_ptr< raw_fd_ostream > CreateInfoOutputFile()
Return a file stream to print our output on.
void print()
Prints out timing information and then resets the timers.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool isRunning() const
Check if the timer is currently running.
auto formatv(const char *Fmt, Ts &&... Vals) -> formatv_object< decltype(std::make_tuple(detail::build_format_adapter(std::forward< Ts >(Vals))...))>
static cl::opt< bool, true > EnableTimingPerRun("time-passes-per-run", cl::location(TimePassesPerRun), cl::Hidden, cl::desc("Time each pass run, printing elapsed time for each run on exit"), cl::callback([](const bool &) { TimePassesIsEnabled=true;}))
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
bool isSpecialPass(StringRef PassID, const std::vector< StringRef > &Specials)
This class implements an extremely fast bulk output stream that can only output to a stream.
LLVM_NODISCARD std::string str() const
str - Get the contents as an std::string.
void registerBeforeAnalysisCallback(CallableT C)
void setOutStream(raw_ostream &OutStream)
Set a custom output stream for subsequent reporting.
constexpr LLVM_NODISCARD bool empty() const
empty - Check if the string is empty.
Timer * getPassTimer(Pass *)
Request the timer for this legacy-pass-manager's pass instance.
std::lock_guard< SmartMutex< mt_only > > SmartScopedLock
initializer< Ty > init(const Ty &Val)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
void stopTimer()
Stop the timer.
void registerAfterAnalysisCallback(CallableT C)
StringRef - Represent a constant reference to a string, i.e.
void registerCallbacks(PassInstrumentationCallbacks &PIC)
void registerAfterPassInvalidatedCallback(CallableT C)
bool TimePassesPerRun
If TimePassesPerRun is true, there would be one line of report for each pass invocation.
The TimerGroup class is used to group together related timers into a single report that is printed wh...
void registerAfterPassCallback(CallableT C)
Pass interface - Implemented by all 'passes'.
This class manages callbacks registration, as well as provides a way for PassInstrumentation to pass ...
This class implements -time-passes functionality for new pass manager.
static cl::opt< bool, true > EnableTiming("time-passes", cl::location(TimePassesIsEnabled), cl::Hidden, cl::desc("Time each pass, printing elapsed time for each on exit"))
cb< typename detail::callback_traits< F >::result_type, typename detail::callback_traits< F >::arg_type > callback(F CB)
static const char PassName[]