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 | ca8f986f63c12120387f90e7bae23b7b787d3d6d (patch) | |
tree | fa503b75fb5b1c2f6c4db2da6f0129b352b685d4 /llvm/lib/Support/Statistic.cpp | |
parent | 1fdf01026b4770f372446e6053437623b9f6a4d5 (diff) | |
download | bcm5719-llvm-ca8f986f63c12120387f90e7bae23b7b787d3d6d.tar.gz bcm5719-llvm-ca8f986f63c12120387f90e7bae23b7b787d3d6d.zip |
Use atomic operations when accessing statistics, and make the lazy initialization of statistics actually threadsafe.
llvm-svn: 74005
Diffstat (limited to 'llvm/lib/Support/Statistic.cpp')
-rw-r--r-- | llvm/lib/Support/Statistic.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/llvm/lib/Support/Statistic.cpp b/llvm/lib/Support/Statistic.cpp index 6c652f8d3f1..33570b0ee53 100644 --- a/llvm/lib/Support/Statistic.cpp +++ b/llvm/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 { |