Changeset View
Changeset View
Standalone View
Standalone View
lib/Support/Statistic.cpp
Show All 22 Lines | |||||
#include "llvm/ADT/Statistic.h" | #include "llvm/ADT/Statistic.h" | ||||
#include "llvm/ADT/StringExtras.h" | #include "llvm/ADT/StringExtras.h" | ||||
#include "llvm/Support/CommandLine.h" | #include "llvm/Support/CommandLine.h" | ||||
#include "llvm/Support/Debug.h" | #include "llvm/Support/Debug.h" | ||||
#include "llvm/Support/Format.h" | #include "llvm/Support/Format.h" | ||||
#include "llvm/Support/ManagedStatic.h" | #include "llvm/Support/ManagedStatic.h" | ||||
#include "llvm/Support/Mutex.h" | #include "llvm/Support/Mutex.h" | ||||
#include "llvm/Support/MutexGuard.h" | |||||
#include "llvm/Support/raw_ostream.h" | #include "llvm/Support/raw_ostream.h" | ||||
#include <algorithm> | #include <algorithm> | ||||
#include <cstring> | #include <cstring> | ||||
using namespace llvm; | using namespace llvm; | ||||
// CreateInfoOutputFile - Return a file stream to print our output on. | // CreateInfoOutputFile - Return a file stream to print our output on. | ||||
namespace llvm { extern raw_ostream *CreateInfoOutputFile(); } | namespace llvm { extern raw_ostream *CreateInfoOutputFile(); } | ||||
Show All 19 Lines | public: | ||||
void addStatistic(const Statistic *S) { | void addStatistic(const Statistic *S) { | ||||
Stats.push_back(S); | Stats.push_back(S); | ||||
} | } | ||||
}; | }; | ||||
} | } | ||||
static ManagedStatic<StatisticInfo> StatInfo; | static ManagedStatic<StatisticInfo> StatInfo; | ||||
static ManagedStatic<sys::SmartMutex<true> > StatLock; | static ManagedStatic<sys::RecursiveDebugMutex> StatLock; | ||||
/// RegisterStatistic - The first time a statistic is bumped, this method is | /// RegisterStatistic - The first time a statistic is bumped, this method is | ||||
/// called. | /// called. | ||||
void Statistic::RegisterStatistic() { | void Statistic::RegisterStatistic() { | ||||
// If stats are enabled, inform StatInfo that this statistic should be | // If stats are enabled, inform StatInfo that this statistic should be | ||||
// printed. | // printed. | ||||
sys::SmartScopedLock<true> Writer(*StatLock); | llvm::MutexGuard Writer(*StatLock); | ||||
if (!Initialized) { | if (!Initialized) { | ||||
if (Enabled) | if (Enabled) | ||||
StatInfo->addStatistic(this); | StatInfo->addStatistic(this); | ||||
TsanHappensBefore(this); | TsanHappensBefore(this); | ||||
sys::MemoryFence(); | sys::MemoryFence(); | ||||
// Remember we have been registered. | // Remember we have been registered. | ||||
TsanIgnoreWritesBegin(); | TsanIgnoreWritesBegin(); | ||||
▲ Show 20 Lines • Show All 82 Lines • Show Last 20 Lines |