diff options
-rw-r--r-- | llvm/include/llvm/ADT/Statistic.h | 2 | ||||
-rw-r--r-- | llvm/lib/Support/Statistic.cpp | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/llvm/include/llvm/ADT/Statistic.h b/llvm/include/llvm/ADT/Statistic.h index c541383332e..0f797ec8de2 100644 --- a/llvm/include/llvm/ADT/Statistic.h +++ b/llvm/include/llvm/ADT/Statistic.h @@ -151,7 +151,7 @@ protected: static llvm::Statistic VARNAME = {DEBUG_TYPE, #VARNAME, DESC, {0}, false} /// \brief Enable the collection and printing of statistics. -void EnableStatistics(); +void EnableStatistics(bool PrintOnExit = true); /// \brief Check if statistics are enabled. bool AreStatisticsEnabled(); diff --git a/llvm/lib/Support/Statistic.cpp b/llvm/lib/Support/Statistic.cpp index 774778143c2..d299bfcae46 100644 --- a/llvm/lib/Support/Statistic.cpp +++ b/llvm/lib/Support/Statistic.cpp @@ -45,6 +45,7 @@ static cl::opt<bool> StatsAsJSON("stats-json", cl::desc("Display statistics as json data")); static bool Enabled; +static bool PrintOnExit; namespace { /// StatisticInfo - This class is used in a ManagedStatic so that it is created @@ -91,12 +92,13 @@ void Statistic::RegisterStatistic() { // Print information when destroyed, iff command line option is specified. StatisticInfo::~StatisticInfo() { - if (::Stats) + if (::Stats || PrintOnExit) llvm::PrintStatistics(); } -void llvm::EnableStatistics() { +void llvm::EnableStatistics(bool PrintOnExit) { Enabled = true; + ::PrintOnExit = PrintOnExit; } bool llvm::AreStatisticsEnabled() { |