26 #ifndef LLVM_ADT_STATISTIC_H 27 #define LLVM_ADT_STATISTIC_H 29 #include "llvm/Config/llvm-config.h" 38 #if !defined(NDEBUG) || LLVM_FORCE_ENABLE_STATS 39 #define LLVM_ENABLE_STATS 1 56 unsigned getValue()
const {
return Value.load(std::memory_order_relaxed); }
62 void construct(
const char *debugtype,
const char *
name,
const char *desc) {
63 DebugType = debugtype;
75 Value.store(Val, std::memory_order_relaxed);
80 Value.fetch_add(1, std::memory_order_relaxed);
86 return Value.fetch_add(1, std::memory_order_relaxed);
90 Value.fetch_sub(1, std::memory_order_relaxed);
96 return Value.fetch_sub(1, std::memory_order_relaxed);
102 Value.fetch_add(V, std::memory_order_relaxed);
109 Value.fetch_sub(V, std::memory_order_relaxed);
114 unsigned PrevMax = Value.load(std::memory_order_relaxed);
117 while (V > PrevMax && !Value.compare_exchange_weak(
118 PrevMax, V, std::memory_order_relaxed)) {
123 #else // Statistics are disabled in release builds. 155 #endif // LLVM_ENABLE_STATS 159 if (!Initialized.load(std::memory_order_acquire))
169 #define STATISTIC(VARNAME, DESC) \ 170 static llvm::Statistic VARNAME = {DEBUG_TYPE, #VARNAME, DESC, {0}, {false}} 200 const std::vector<std::pair<StringRef, unsigned>>
GetStatistics();
219 #endif // LLVM_ADT_STATISTIC_H
std::atomic< unsigned > Value
const Statistic & operator=(unsigned Val)
void EnableStatistics(bool PrintOnExit=true)
Enable the collection and printing of statistics.
This class represents lattice values for constants.
void construct(const char *debugtype, const char *name, const char *desc)
construct - This should only be called for non-global statistics.
void updateMax(unsigned V)
void RegisterStatistic()
RegisterStatistic - The first time a statistic is bumped, this method is called.
void ResetStatistics()
Reset the statistics.
const Statistic & operator+=(unsigned V)
const char * getDebugType() const
const Statistic & operator++()
const Statistic & operator--()
std::unique_ptr< raw_fd_ostream > CreateInfoOutputFile()
Return a file stream to print our output on.
const std::vector< std::pair< StringRef, unsigned > > GetStatistics()
Get the statistics.
void PrintStatisticsJSON(raw_ostream &OS)
Print statistics in JSON format.
const Statistic & operator-=(unsigned V)
unsigned getValue() const
const char * getDesc() const
const char * getName() const
void PrintStatistics()
Print statistics to the file returned by CreateInfoOutputFile().
std::atomic< bool > Initialized
bool AreStatisticsEnabled()
Check if statistics are enabled.