[llvm] r282532 - Statistic: Bring back printing on exit by default

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 27 12:38:55 PDT 2016


Author: matze
Date: Tue Sep 27 14:38:55 2016
New Revision: 282532

URL: http://llvm.org/viewvc/llvm-project?rev=282532&view=rev
Log:
Statistic: Bring back printing on exit by default

Turns out several external projects relied on llvm printing statistics
on exit. Let's go back to this behaviour by default and have an optional
parameter to disable it.

Modified:
    llvm/trunk/include/llvm/ADT/Statistic.h
    llvm/trunk/lib/Support/Statistic.cpp

Modified: llvm/trunk/include/llvm/ADT/Statistic.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/Statistic.h?rev=282532&r1=282531&r2=282532&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ADT/Statistic.h (original)
+++ llvm/trunk/include/llvm/ADT/Statistic.h Tue Sep 27 14:38:55 2016
@@ -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();

Modified: llvm/trunk/lib/Support/Statistic.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Statistic.cpp?rev=282532&r1=282531&r2=282532&view=diff
==============================================================================
--- llvm/trunk/lib/Support/Statistic.cpp (original)
+++ llvm/trunk/lib/Support/Statistic.cpp Tue Sep 27 14:38:55 2016
@@ -45,6 +45,7 @@ static cl::opt<bool> StatsAsJSON("stats-
                                  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() {




More information about the llvm-commits mailing list