diff options
author | Owen Anderson <resistor@mac.com> | 2009-06-19 17:45:12 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-06-19 17:45:12 +0000 |
commit | 8e1c17aa5af9b01d9e1d36abd66aade615d097b7 (patch) | |
tree | b722869875cb46bb72f6828d8ed9f3cb01e5fe17 | |
parent | 958e292c7a71e9105df2d46ac15dcd1f3cfa0ee2 (diff) | |
download | external_llvm-8e1c17aa5af9b01d9e1d36abd66aade615d097b7.zip external_llvm-8e1c17aa5af9b01d9e1d36abd66aade615d097b7.tar.gz external_llvm-8e1c17aa5af9b01d9e1d36abd66aade615d097b7.tar.bz2 |
Move the memory fences out of the path for single-threaded mode.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73775 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/VMCore/Pass.cpp | 11 | ||||
-rw-r--r-- | lib/VMCore/Type.cpp | 18 |
2 files changed, 15 insertions, 14 deletions
diff --git a/lib/VMCore/Pass.cpp b/lib/VMCore/Pass.cpp index 3fce83d..e943e31 100644 --- a/lib/VMCore/Pass.cpp +++ b/lib/VMCore/Pass.cpp @@ -198,9 +198,9 @@ static PassRegistrar *getPassRegistrar() { // Use double-checked locking to safely initialize the registrar when // we're running in multithreaded mode. PassRegistrar* tmp = PassRegistrarObj; - sys::MemoryFence(); - if (!tmp) { - if (llvm_is_multithreaded()) { + if (llvm_is_multithreaded()) { + sys::MemoryFence(); + if (!tmp) { llvm_acquire_global_lock(); tmp = PassRegistrarObj; if (!tmp) { @@ -209,10 +209,11 @@ static PassRegistrar *getPassRegistrar() { PassRegistrarObj = tmp; } llvm_release_global_lock(); - } else { - PassRegistrarObj = new PassRegistrar(); } + } else if (!tmp) { + PassRegistrarObj = new PassRegistrar(); } + return PassRegistrarObj; } diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index 66eb10a..5df7f12 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -458,9 +458,9 @@ void DerivedType::dropAllTypeUses() { static Type *AlwaysOpaqueTy = 0; static PATypeHolder* Holder = 0; Type *tmp = AlwaysOpaqueTy; - sys::MemoryFence(); - if (!tmp) { - if (llvm_is_multithreaded()) { + if (llvm_is_multithreaded()) { + sys::MemoryFence(); + if (!tmp) { llvm_acquire_global_lock(); tmp = AlwaysOpaqueTy; if (!tmp) { @@ -472,12 +472,12 @@ void DerivedType::dropAllTypeUses() { } llvm_release_global_lock(); - } else { - AlwaysOpaqueTy = OpaqueType::get(); - Holder = new PATypeHolder(AlwaysOpaqueTy); - } - } - + } + } else { + AlwaysOpaqueTy = OpaqueType::get(); + Holder = new PATypeHolder(AlwaysOpaqueTy); + } + ContainedTys[0] = AlwaysOpaqueTy; // Change the rest of the types to be Int32Ty's. It doesn't matter what we |