44 cl::desc(
"Enable statistics output from program (available with Asserts)"),
48 cl::desc(
"Display statistics as json data"),
61 std::vector<Statistic*>
Stats;
70 using const_iterator = std::vector<Statistic *>::const_iterator;
79 const_iterator
begin()
const {
return Stats.
begin(); }
80 const_iterator
end()
const {
return Stats.
end(); }
103 if (!Initialized.load(std::memory_order_relaxed)) {
108 if (Initialized.load(std::memory_order_relaxed))
110 if (
Stats || Enabled)
111 SI.addStatistic(
this);
114 Initialized.store(
true, std::memory_order_release);
118 StatisticInfo::StatisticInfo() {
124 StatisticInfo::~StatisticInfo() {
125 if (::
Stats || PrintOnExit)
135 return Enabled ||
Stats;
141 if (
int Cmp = std::strcmp(LHS->
getDebugType(), RHS->getDebugType()))
144 if (
int Cmp = std::strcmp(LHS->
getName(), RHS->getName()))
147 return std::strcmp(LHS->
getDesc(), RHS->getDesc()) < 0;
151 void StatisticInfo::reset() {
158 for (
auto *Stat :
Stats) {
161 Stat->Initialized =
false;
177 unsigned MaxDebugTypeLen = 0, MaxValLen = 0;
178 for (
size_t i = 0, e = Stats.Stats.size(); i != e; ++i) {
180 (
unsigned)
utostr(Stats.Stats[i]->getValue()).
size());
181 MaxDebugTypeLen =
std::max(MaxDebugTypeLen,
182 (
unsigned)std::strlen(Stats.Stats[i]->getDebugType()));
188 OS <<
"===" << std::string(73,
'-') <<
"===\n" 189 <<
" ... Statistics Collected ...\n" 190 <<
"===" << std::string(73,
'-') <<
"===\n\n";
193 for (
size_t i = 0, e = Stats.Stats.size(); i != e; ++i)
194 OS <<
format(
"%*u %-*s - %s\n",
195 MaxValLen, Stats.Stats[i]->getValue(),
196 MaxDebugTypeLen, Stats.Stats[i]->getDebugType(),
197 Stats.Stats[i]->getDesc());
211 const char *delim =
"";
212 for (
const Statistic *Stat : Stats.Stats) {
215 "Statistic group/type name is simple.");
217 "Statistic name is simple");
230 #if LLVM_ENABLE_STATS 235 if (Stats.Stats.empty())
return;
251 (*OutStream) <<
"Statistics are disabled. " 252 <<
"Build with asserts or with -DLLVM_ENABLE_STATS\n";
259 std::vector<std::pair<StringRef, unsigned>> ReturnStats;
261 for (
const auto &Stat : StatInfo->statistics())
262 ReturnStats.emplace_back(Stat->getName(), Stat->getValue());
const_iterator end(StringRef path)
Get end iterator over path.
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
void EnableStatistics(bool PrintOnExit=true)
Enable the collection and printing of statistics.
const_iterator begin(StringRef path, Style style=Style::native)
Get begin iterator over path.
This class represents lattice values for constants.
format_object< Ts... > format(const char *Fmt, const Ts &... Vals)
These are helper functions used to produce formatted output.
SmartMutex - A mutex with a compile time constant parameter that indicates whether this mutex should ...
void RegisterStatistic()
RegisterStatistic - The first time a statistic is bumped, this method is called.
void ResetStatistics()
Reset the statistics.
const char * getDebugType() const
friend const_iterator begin(StringRef path, Style style)
Get begin iterator over path.
static ManagedStatic< StatisticInfo > StatInfo
std::unique_ptr< raw_fd_ostream > CreateInfoOutputFile()
Return a file stream to print our output on.
friend const_iterator end(StringRef path)
Get end iterator over path.
const std::vector< std::pair< StringRef, unsigned > > GetStatistics()
Get the statistics.
void sort(IteratorTy Start, IteratorTy End)
void PrintStatisticsJSON(raw_ostream &OS)
Print statistics in JSON format.
auto size(R &&Range, typename std::enable_if< std::is_same< typename std::iterator_traits< decltype(Range.begin())>::iterator_category, std::random_access_iterator_tag >::value, void >::type *=nullptr) -> decltype(std::distance(Range.begin(), Range.end()))
Get the size of a range.
unsigned getValue() const
const char * getDesc() const
std::string utostr(uint64_t X, bool isNeg=false)
A range adaptor for a pair of iterators.
static const char * printAllJSONValues(raw_ostream &OS, const char *delim)
Prints all timers as JSON key/value pairs.
const char * getName() const
void PrintStatistics()
Print statistics to the file returned by CreateInfoOutputFile().
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static void ConstructTimerLists()
Ensure global timer group lists are initialized.
This class implements an extremely fast bulk output stream that can only output to a stream...
static cl::opt< bool > Stats("stats", cl::desc("Enable statistics output from program (available with Asserts)"), cl::Hidden)
-stats - Command line option to cause transformations to emit stats about what they did...
ManagedStatic - This transparently changes the behavior of global statics to be lazily constructed on...
static ManagedStatic< sys::SmartMutex< true > > StatLock
bool AreStatisticsEnabled()
Check if statistics are enabled.
static cl::opt< bool > StatsAsJSON("stats-json", cl::desc("Display statistics as json data"), cl::Hidden)