[llvm-commits] [llvm] r73775 - in /llvm/trunk/lib/VMCore: Pass.cpp Type.cpp

Owen Anderson resistor at mac.com
Fri Jun 19 10:45:33 PDT 2009


Author: resistor
Date: Fri Jun 19 12:45:12 2009
New Revision: 73775

URL: http://llvm.org/viewvc/llvm-project?rev=73775&view=rev
Log:
Move the memory fences out of the path for single-threaded mode.

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

Modified: llvm/trunk/lib/VMCore/Pass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Pass.cpp?rev=73775&r1=73774&r2=73775&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Pass.cpp (original)
+++ llvm/trunk/lib/VMCore/Pass.cpp Fri Jun 19 12:45:12 2009
@@ -198,9 +198,9 @@
   // 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 @@
         PassRegistrarObj = tmp;
       }
       llvm_release_global_lock();
-    } else {
-      PassRegistrarObj = new PassRegistrar();
     }
+  } else if (!tmp) {
+    PassRegistrarObj = new PassRegistrar();
   }
+  
   return PassRegistrarObj;
 }
 

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

==============================================================================
--- llvm/trunk/lib/VMCore/Type.cpp (original)
+++ llvm/trunk/lib/VMCore/Type.cpp Fri Jun 19 12:45:12 2009
@@ -458,9 +458,9 @@
     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 @@
         }
       
         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





More information about the llvm-commits mailing list