25 #ifndef LLVM_ADT_STATISTIC_H 26 #define LLVM_ADT_STATISTIC_H 28 #include "llvm/Config/llvm-config.h" 37 #if !defined(NDEBUG) || LLVM_FORCE_ENABLE_STATS 38 #define LLVM_ENABLE_STATS 1 53 StatisticBase(
const char *DebugType,
const char *Name,
const char *Desc)
54 : DebugType(DebugType), Name(Name), Desc(Desc) {}
69 unsigned getValue()
const {
return Value.load(std::memory_order_relaxed); }
72 operator unsigned()
const {
return getValue(); }
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)) {
125 if (!Initialized.load(std::memory_order_acquire))
130 void RegisterStatistic();
159 #if LLVM_ENABLE_STATS 167 #define STATISTIC(VARNAME, DESC) \ 168 static llvm::Statistic VARNAME = {DEBUG_TYPE, #VARNAME, DESC} 172 #define ALWAYS_ENABLED_STATISTIC(VARNAME, DESC) \ 173 static llvm::TrackingStatistic VARNAME = {DEBUG_TYPE, #VARNAME, DESC} 203 const std::vector<std::pair<StringRef, unsigned>>
GetStatistics();
222 #endif // LLVM_ADT_STATISTIC_H
const NoopStatistic & operator-=(const unsigned &V)
This class represents lattice values for constants.
const TrackingStatistic & operator++()
void updateMax(unsigned V)
void updateMax(unsigned V)
const TrackingStatistic & operator=(unsigned Val)
void ResetStatistics()
Reset the statistics.
unsigned getValue() const
const NoopStatistic & operator=(unsigned Val)
const char * getName() const
const char * getDesc() const
TrackingStatistic(const char *DebugType, const char *Name, const char *Desc)
std::atomic< unsigned > Value
std::unique_ptr< raw_fd_ostream > CreateInfoOutputFile()
Return a file stream to print our output on.
initializer< Ty > init(const Ty &Val)
const NoopStatistic & operator+=(const unsigned &V)
const NoopStatistic & operator--()
std::atomic< bool > Initialized
TrackingStatistic & init()
const std::vector< std::pair< StringRef, unsigned > > GetStatistics()
Get the statistics.
const TrackingStatistic & operator--()
void PrintStatisticsJSON(raw_ostream &OS)
Print statistics in JSON format.
unsigned getValue() const
StatisticBase(const char *DebugType, const char *Name, const char *Desc)
const char * getDebugType() const
const TrackingStatistic & operator+=(unsigned V)
const NoopStatistic & operator++()
void PrintStatistics()
Print statistics to the file returned by CreateInfoOutputFile().
void EnableStatistics(bool DoPrintOnExit=true)
Enable the collection and printing of statistics.
const TrackingStatistic & operator-=(unsigned V)
bool AreStatisticsEnabled()
Check if statistics are enabled.