[llvm-commits] [llvm] r73703 - /llvm/trunk/lib/VMCore/Type.cpp

Owen Anderson resistor at mac.com
Thu Jun 18 09:17:50 PDT 2009


Author: resistor
Date: Thu Jun 18 11:17:42 2009
New Revision: 73703

URL: http://llvm.org/viewvc/llvm-project?rev=73703&view=rev
Log:
Fix the double checked locking in this file too.

Modified:
    llvm/trunk/lib/VMCore/Type.cpp

Modified: llvm/trunk/lib/VMCore/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=73703&r1=73702&r2=73703&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Type.cpp (original)
+++ llvm/trunk/lib/VMCore/Type.cpp Thu Jun 18 11:17:42 2009
@@ -455,12 +455,14 @@
     // 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;





More information about the llvm-commits mailing list