summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Statistic.cpp
diff options
context:
space:
mode:
authorDaniel Sanders <daniel_l_sanders@apple.com>2018-03-05 17:52:43 +0000
committerDaniel Sanders <daniel_l_sanders@apple.com>2018-03-05 17:52:43 +0000
commit7612f85df5ffabe85d060f953f1c22079bfccd78 (patch)
tree8a095c22beea50ee613161cd708c69c8f55aced5 /llvm/lib/Support/Statistic.cpp
parent1578a0a55d8138e886d739fd195cf4a65f47d091 (diff)
downloadbcm5719-llvm-7612f85df5ffabe85d060f953f1c22079bfccd78.tar.gz
bcm5719-llvm-7612f85df5ffabe85d060f953f1c22079bfccd78.zip
Revert r326723: Make STATISTIC() values available programmatically
Despite building cleanly on my machine in three separate configs, it's failing on pretty much all bots due to missing includes among other things. Investigating. llvm-svn: 326726
Diffstat (limited to 'llvm/lib/Support/Statistic.cpp')
-rw-r--r--llvm/lib/Support/Statistic.cpp30
1 files changed, 5 insertions, 25 deletions
diff --git a/llvm/lib/Support/Statistic.cpp b/llvm/lib/Support/Statistic.cpp
index 67b07162b9a..370274dc299 100644
--- a/llvm/lib/Support/Statistic.cpp
+++ b/llvm/lib/Support/Statistic.cpp
@@ -52,14 +52,11 @@ static bool Enabled;
static bool PrintOnExit;
namespace {
-/// This class is used in a ManagedStatic so that it is created on demand (when
-/// the first statistic is bumped) and destroyed only when llvm_shutdown is
-/// called. We print statistics from the destructor.
-/// This class is also used to look up statistic values from applications that
-/// use LLVM.
+/// StatisticInfo - This class is used in a ManagedStatic so that it is created
+/// on demand (when the first statistic is bumped) and destroyed only when
+/// llvm_shutdown is called. We print statistics from the destructor.
class StatisticInfo {
std::vector<const Statistic*> Stats;
-
friend void llvm::PrintStatistics();
friend void llvm::PrintStatistics(raw_ostream &OS);
friend void llvm::PrintStatisticsJSON(raw_ostream &OS);
@@ -67,22 +64,14 @@ class StatisticInfo {
/// Sort statistics by debugtype,name,description.
void sort();
public:
- using const_iterator = std::vector<const Statistic *>::const_iterator;
-
StatisticInfo();
~StatisticInfo();
void addStatistic(const Statistic *S) {
Stats.push_back(S);
}
-
- const_iterator begin() const { return Stats.begin(); }
- const_iterator end() const { return Stats.end(); }
- iterator_range<const_iterator> statistics() const {
- return {begin(), end()};
- }
};
-} // end anonymous namespace
+}
static ManagedStatic<StatisticInfo> StatInfo;
static ManagedStatic<sys::SmartMutex<true> > StatLock;
@@ -191,7 +180,7 @@ void llvm::PrintStatisticsJSON(raw_ostream &OS) {
}
void llvm::PrintStatistics() {
-#if LLVM_ENABLE_STATS
+#if !defined(NDEBUG) || defined(LLVM_ENABLE_STATS)
StatisticInfo &Stats = *StatInfo;
// Statistics not enabled?
@@ -216,12 +205,3 @@ void llvm::PrintStatistics() {
}
#endif
}
-
-const std::vector<std::pair<StringRef, unsigned>> llvm::GetStatistics() {
- sys::SmartScopedLock<true> Reader(*StatLock);
- std::vector<std::pair<StringRef, unsigned>> ReturnStats;
-
- for (const auto &Stat : StatInfo->statistics())
- ReturnStats.emplace_back(Stat->getName(), Stat->getValue());
- return ReturnStats;
-}
OpenPOWER on IntegriCloud