Fix the double checked locking in this file too.
authorOwen Anderson <resistor@mac.com>
Thu, 18 Jun 2009 16:17:42 +0000 (16:17 +0000)
committerOwen Anderson <resistor@mac.com>
Thu, 18 Jun 2009 16:17:42 +0000 (16:17 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73703 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/Type.cpp

index 0add0af3b849f00d84d549b7397b17c27ece9f78..b7adaddd9a161a97210ad219c2806ea2ae8fde4a 100644 (file)
@@ -455,12 +455,14 @@ void DerivedType::dropAllTypeUses() {
     // that will never get resolved, thus will always be abstract.
     static Type *AlwaysOpaqueTy = 0;
     static PATypeHolder* Holder = 0;
-    if (!AlwaysOpaqueTy) {
+    Type *tmp = AlwaysOpaqueTy;
+    sys::MemoryFence();
+    if (!tmp) {
       if (llvm_is_multithreaded()) {
         llvm_acquire_global_lock();
-      
-        if (!AlwaysOpaqueTy) {
-          Type *tmp = OpaqueType::get();
+        tmp = AlwaysOpaqueTy;
+        if (!tmp) {
+          tmp = OpaqueType::get();
           PATypeHolder* tmp2 = new PATypeHolder(AlwaysOpaqueTy);
           sys::MemoryFence();
           AlwaysOpaqueTy = tmp;