aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/llvm/lib/Support/Statistic.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/llvm/lib/Support/Statistic.cpp')
-rw-r--r--contrib/llvm-project/llvm/lib/Support/Statistic.cpp41
1 files changed, 20 insertions, 21 deletions
diff --git a/contrib/llvm-project/llvm/lib/Support/Statistic.cpp b/contrib/llvm-project/llvm/lib/Support/Statistic.cpp
index e4f0535d21aa..25f13871e2e4 100644
--- a/contrib/llvm-project/llvm/lib/Support/Statistic.cpp
+++ b/contrib/llvm-project/llvm/lib/Support/Statistic.cpp
@@ -38,7 +38,7 @@ using namespace llvm;
/// -stats - Command line option to cause transformations to emit stats about
/// what they did.
///
-static cl::opt<bool> Stats(
+static cl::opt<bool> EnableStats(
"stats",
cl::desc("Enable statistics output from program (available with Asserts)"),
cl::Hidden);
@@ -57,7 +57,7 @@ namespace {
/// This class is also used to look up statistic values from applications that
/// use LLVM.
class StatisticInfo {
- std::vector<Statistic*> Stats;
+ std::vector<TrackingStatistic *> Stats;
friend void llvm::PrintStatistics();
friend void llvm::PrintStatistics(raw_ostream &OS);
@@ -66,14 +66,12 @@ class StatisticInfo {
/// Sort statistics by debugtype,name,description.
void sort();
public:
- using const_iterator = std::vector<Statistic *>::const_iterator;
+ using const_iterator = std::vector<TrackingStatistic *>::const_iterator;
StatisticInfo();
~StatisticInfo();
- void addStatistic(Statistic *S) {
- Stats.push_back(S);
- }
+ void addStatistic(TrackingStatistic *S) { Stats.push_back(S); }
const_iterator begin() const { return Stats.begin(); }
const_iterator end() const { return Stats.end(); }
@@ -90,7 +88,7 @@ static ManagedStatic<sys::SmartMutex<true> > StatLock;
/// RegisterStatistic - The first time a statistic is bumped, this method is
/// called.
-void Statistic::RegisterStatistic() {
+void TrackingStatistic::RegisterStatistic() {
// If stats are enabled, inform StatInfo that this statistic should be
// printed.
// llvm_shutdown calls destructors while holding the ManagedStatic mutex.
@@ -106,7 +104,7 @@ void Statistic::RegisterStatistic() {
// Check Initialized again after acquiring the lock.
if (Initialized.load(std::memory_order_relaxed))
return;
- if (Stats || Enabled)
+ if (EnableStats || Enabled)
SI.addStatistic(this);
// Remember we have been registered.
@@ -121,29 +119,30 @@ StatisticInfo::StatisticInfo() {
// Print information when destroyed, iff command line option is specified.
StatisticInfo::~StatisticInfo() {
- if (::Stats || PrintOnExit)
+ if (EnableStats || PrintOnExit)
llvm::PrintStatistics();
}
-void llvm::EnableStatistics(bool PrintOnExit) {
+void llvm::EnableStatistics(bool DoPrintOnExit) {
Enabled = true;
- ::PrintOnExit = PrintOnExit;
+ PrintOnExit = DoPrintOnExit;
}
bool llvm::AreStatisticsEnabled() {
- return Enabled || Stats;
+ return Enabled || EnableStats;
}
void StatisticInfo::sort() {
- llvm::stable_sort(Stats, [](const Statistic *LHS, const Statistic *RHS) {
- if (int Cmp = std::strcmp(LHS->getDebugType(), RHS->getDebugType()))
- return Cmp < 0;
+ llvm::stable_sort(
+ Stats, [](const TrackingStatistic *LHS, const TrackingStatistic *RHS) {
+ if (int Cmp = std::strcmp(LHS->getDebugType(), RHS->getDebugType()))
+ return Cmp < 0;
- if (int Cmp = std::strcmp(LHS->getName(), RHS->getName()))
- return Cmp < 0;
+ if (int Cmp = std::strcmp(LHS->getName(), RHS->getName()))
+ return Cmp < 0;
- return std::strcmp(LHS->getDesc(), RHS->getDesc()) < 0;
- });
+ return std::strcmp(LHS->getDesc(), RHS->getDesc()) < 0;
+ });
}
void StatisticInfo::reset() {
@@ -207,7 +206,7 @@ void llvm::PrintStatisticsJSON(raw_ostream &OS) {
// Print all of the statistics.
OS << "{\n";
const char *delim = "";
- for (const Statistic *Stat : Stats.Stats) {
+ for (const TrackingStatistic *Stat : Stats.Stats) {
OS << delim;
assert(yaml::needsQuotes(Stat->getDebugType()) == yaml::QuotingType::None &&
"Statistic group/type name is simple.");
@@ -243,7 +242,7 @@ void llvm::PrintStatistics() {
// Check if the -stats option is set instead of checking
// !Stats.Stats.empty(). In release builds, Statistics operators
// do nothing, so stats are never Registered.
- if (Stats) {
+ if (EnableStats) {
// Get the stream to write to.
std::unique_ptr<raw_ostream> OutStream = CreateInfoOutputFile();
(*OutStream) << "Statistics are disabled. "