Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 757d062

Browse files
matzeMatzeB
authored andcommitted
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@282532 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 2b800b6 commit 757d062

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

include/llvm/ADT/Statistic.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ class Statistic {
151151
static llvm::Statistic VARNAME = {DEBUG_TYPE, #VARNAME, DESC, {0}, false}
152152

153153
/// \brief Enable the collection and printing of statistics.
154-
void EnableStatistics();
154+
void EnableStatistics(bool PrintOnExit = true);
155155

156156
/// \brief Check if statistics are enabled.
157157
bool AreStatisticsEnabled();

lib/Support/Statistic.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ static cl::opt<bool> StatsAsJSON("stats-json",
4545
cl::desc("Display statistics as json data"));
4646

4747
static bool Enabled;
48+
static bool PrintOnExit;
4849

4950
namespace {
5051
/// StatisticInfo - This class is used in a ManagedStatic so that it is created
@@ -91,12 +92,13 @@ void Statistic::RegisterStatistic() {
9192

9293
// Print information when destroyed, iff command line option is specified.
9394
StatisticInfo::~StatisticInfo() {
94-
if (::Stats)
95+
if (::Stats || PrintOnExit)
9596
llvm::PrintStatistics();
9697
}
9798

98-
void llvm::EnableStatistics() {
99+
void llvm::EnableStatistics(bool PrintOnExit) {
99100
Enabled = true;
101+
::PrintOnExit = PrintOnExit;
100102
}
101103

102104
bool llvm::AreStatisticsEnabled() {

0 commit comments

Comments
 (0)