diff options
author | Owen Anderson <resistor@mac.com> | 2009-06-23 21:19:38 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-06-23 21:19:38 +0000 |
commit | 92915e31e988c1b89a07c035029dc2f289afb789 (patch) | |
tree | b2e33caf6d5eb3da25d4936e8de590164b1fb94f /lib/Support/Statistic.cpp | |
parent | e0fa0b42b2b5e95c81ceff19401c7bb2152dd22a (diff) |
Use atomic operations when accessing statistics, and make the lazy initialization of statistics actually threadsafe.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@74005 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Support/Statistic.cpp')
-rw-r--r-- | lib/Support/Statistic.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/Support/Statistic.cpp b/lib/Support/Statistic.cpp index 6c652f8d3f..33570b0ee5 100644 --- a/lib/Support/Statistic.cpp +++ b/lib/Support/Statistic.cpp @@ -66,10 +66,14 @@ 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. - Initialized = true; + if (!Initialized) { + if (Enabled) + StatInfo->addStatistic(this); + + sys::MemoryFence(); + // Remember we have been registered. + Initialized = true; + } } namespace { |