diff options
author | Owen Anderson <resistor@mac.com> | 2009-06-18 16:08:27 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-06-18 16:08:27 +0000 |
commit | 3cfc62aa08c671c4f7fccd21e1ff1af2b07d34b6 (patch) | |
tree | aedf684835da54b2cdcca52b543451fc38b798d2 | |
parent | fd0cfe4bb4782d2b525495dae5096d3709d888c6 (diff) |
As pointed out by Duncan, I accidentally dropped the first MemoryFence of the
double-checked locking pattern here.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73701 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/VMCore/Pass.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/VMCore/Pass.cpp b/lib/VMCore/Pass.cpp index 579f1029ac..70ec108fa1 100644 --- a/lib/VMCore/Pass.cpp +++ b/lib/VMCore/Pass.cpp @@ -197,17 +197,21 @@ static PassRegistrar *getPassRegistrar() { // Use double-checked locking to safely initialize the registrar when // we're running in multithreaded mode. - if (!PassRegistrarObj) { + PassRegistrar* tmp = PassRegistrarObj; + sys::MemoryFence(); + if (!tmp) { if (llvm_is_multithreaded()) { llvm_acquire_global_lock(); - if (!PassRegistrarObj) { - PassRegistrar* tmp = new PassRegistrar(); + tmp = PassRegistrarObj; + if (!tmp) { + tmp = new PassRegistrar(); sys::MemoryFence(); PassRegistrarObj = tmp; } llvm_release_global_lock(); - } else + } else { PassRegistrarObj = new PassRegistrar(); + } } return PassRegistrarObj; } |