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 | a81a9e79cec464115ebd9f30a39c8b6ac7647dcb (patch) | |
tree | b2e33caf6d5eb3da25d4936e8de590164b1fb94f /lib/Support/Statistic.cpp | |
parent | d5d94ef271b64b6f2f31922c7c28359d5118ce6e (diff) | |
download | external_llvm-a81a9e79cec464115ebd9f30a39c8b6ac7647dcb.zip external_llvm-a81a9e79cec464115ebd9f30a39c8b6ac7647dcb.tar.gz external_llvm-a81a9e79cec464115ebd9f30a39c8b6ac7647dcb.tar.bz2 |
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 6c652f8..33570b0 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 { |