Guard the statistics table.
authorOwen Anderson <resistor@mac.com>
Mon, 22 Jun 2009 23:08:27 +0000 (23:08 +0000)
committerOwen Anderson <resistor@mac.com>
Mon, 22 Jun 2009 23:08:27 +0000 (23:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73916 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/Statistic.cpp

index 13acc1b0fa1e541086c40724be001615ee5d0b4d..6c652f8d3f162abcba48d61230b068f50df22c1d 100644 (file)
@@ -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.