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
This commit is contained in:
Owen Anderson 2009-06-18 16:08:27 +00:00
parent fd0cfe4bb4
commit 3cfc62aa08

View File

@ -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;
}