53 "Enable statistics output from program (available with Asserts)"),
56 "stats-json",
cl::desc(
"Display statistics as json data"),
67 std::vector<TrackingStatistic *>
Stats;
76 using const_iterator = std::vector<TrackingStatistic *>::const_iterator;
107 if (!
Initialized.load(std::memory_order_relaxed)) {
115 SI.addStatistic(
this);
118 Initialized.store(
true, std::memory_order_release);
122StatisticInfo::StatisticInfo() {
129StatisticInfo::~StatisticInfo() {
141void StatisticInfo::sort() {
144 if (
int Cmp = std::strcmp(
LHS->getDebugType(),
RHS->getDebugType()))
150 return std::strcmp(
LHS->getDesc(),
RHS->getDesc()) < 0;
154void StatisticInfo::reset() {
161 for (
auto *Stat :
Stats) {
164 Stat->Initialized =
false;
180 unsigned MaxDebugTypeLen = 0, MaxValLen = 0;
182 MaxValLen = std::max(MaxValLen, (
unsigned)utostr(Stat->getValue()).size());
184 std::max(MaxDebugTypeLen, (
unsigned)std::strlen(Stat->getDebugType()));
190 OS <<
"===" << std::string(73,
'-') <<
"===\n"
191 <<
" ... Statistics Collected ...\n"
192 <<
"===" << std::string(73,
'-') <<
"===\n\n";
196 OS <<
format(
"%*" PRIu64
" %-*s - %s\n", MaxValLen, Stat->getValue(),
197 MaxDebugTypeLen, Stat->getDebugType(), Stat->getDesc());
211 const char *delim =
"";
214 assert(yaml::needsQuotes(Stat->getDebugType()) == yaml::QuotingType::None &&
215 "Statistic group/type name is simple.");
216 assert(yaml::needsQuotes(Stat->getName()) == yaml::QuotingType::None &&
217 "Statistic name is simple");
218 OS <<
"\t\"" << Stat->getDebugType() <<
'.' << Stat->getName() <<
"\": "
235 if (
Stats.Stats.empty())
return;
251 (*OutStream) <<
"Statistics are disabled. "
252 <<
"Build with asserts or with -DLLVM_FORCE_ENABLE_STATS\n";
259 std::vector<std::pair<StringRef, uint64_t>> ReturnStats;
261 for (
const auto &Stat :
StatInfo->statistics())
262 ReturnStats.emplace_back(Stat->getName(), Stat->getValue());
block placement Basic Block Placement Stats
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool EnableStats
-stats - Command line option to cause transformations to emit stats about what they did.
static ManagedStatic< StatisticInfo > StatInfo
static ManagedStatic< sys::SmartMutex< true > > StatLock
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
static const char * printAllJSONValues(raw_ostream &OS, const char *delim)
Prints all timers as JSON key/value pairs.
static void constructForStatistics()
Ensure global objects required for statistics printing are initialized.
std::atomic< bool > Initialized
void RegisterStatistic()
RegisterStatistic - The first time a statistic is bumped, this method is called.
StringRef getName() const
Return a constant reference to the value's name.
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
SmartMutex - A mutex with a compile time constant parameter that indicates whether this mutex should ...
LocationClass< Ty > location(Ty &L)
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
const_iterator end(StringRef path)
Get end iterator over path.
std::lock_guard< SmartMutex< mt_only > > SmartScopedLock
This is an optimization pass for GlobalISel generic memory operations.
void stable_sort(R &&Range)
std::unique_ptr< raw_ostream > CreateInfoOutputFile()
Return a stream to print our output on.
void ResetStatistics()
Reset the statistics.
void EnableStatistics(bool DoPrintOnExit=true)
Enable the collection and printing of statistics.
void sort(IteratorTy Start, IteratorTy End)
bool AreStatisticsEnabled()
Check if statistics are enabled.
void initStatisticOptions()
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
void PrintStatistics()
Print statistics to the file returned by CreateInfoOutputFile().
std::vector< std::pair< StringRef, uint64_t > > GetStatistics()
Get the statistics.
void PrintStatisticsJSON(raw_ostream &OS)
Print statistics in JSON format.