summaryrefslogtreecommitdiff
path: root/lib/Support/Statistic.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2009-06-22 23:08:27 +0000
committerOwen Anderson <resistor@mac.com>2009-06-22 23:08:27 +0000
commit5de83afcdc3f4f0edf8caacba523f5d05ee48048 (patch)
tree1e01fd78bfa74d8c4701703ac25069182c4c5d8c /lib/Support/Statistic.cpp
parent521db56182645f34290b4bcd27da0c488c8fcbf9 (diff)
downloadllvm-5de83afcdc3f4f0edf8caacba523f5d05ee48048.tar.gz
llvm-5de83afcdc3f4f0edf8caacba523f5d05ee48048.tar.bz2
llvm-5de83afcdc3f4f0edf8caacba523f5d05ee48048.tar.xz
Guard the statistics table.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73916 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Statistic.cpp')
-rw-r--r--lib/Support/Statistic.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/Support/Statistic.cpp b/lib/Support/Statistic.cpp
index 13acc1b0fa..6c652f8d3f 100644
--- a/lib/Support/Statistic.cpp
+++ b/lib/Support/Statistic.cpp
@@ -25,6 +25,7 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/Streams.h"
+#include "llvm/System/Mutex.h"
#include "llvm/ADT/StringExtras.h"
#include <algorithm>
#include <ostream>
@@ -57,13 +58,14 @@ public:
}
static ManagedStatic<StatisticInfo> StatInfo;
-
+static ManagedStatic<sys::Mutex> StatLock;
/// RegisterStatistic - The first time a statistic is bumped, this method is
/// called.
void Statistic::RegisterStatistic() {
// If stats are enabled, inform StatInfo that this statistic should be
// printed.
+ sys::ScopedLock Writer(&*StatLock);
if (Enabled)
StatInfo->addStatistic(this);
// Remember we have been registered.