[llvm-commits] [llvm] r79731 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Owen Anderson resistor at mac.com
Fri Aug 21 23:32:37 PDT 2009


Author: resistor
Date: Sat Aug 22 01:32:36 2009
New Revision: 79731

URL: http://llvm.org/viewvc/llvm-project?rev=79731&view=rev
Log:
Reapply r79708 with the appropriate fix for the case that still requires locking.

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=79731&r1=79730&r2=79731&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Sat Aug 22 01:32:36 2009
@@ -5022,12 +5022,16 @@
 /// getValueTypeList - Return a pointer to the specified value type.
 ///
 const EVT *SDNode::getValueTypeList(EVT VT) {
-  sys::SmartScopedLock<true> Lock(*VTMutex);
   if (VT.isExtended()) {
+    sys::SmartScopedLock<true> Lock(*VTMutex);
     return &(*EVTs->insert(VT).first);
   } else {
+    // All writes to this location will have the same value, so it's ok
+    // to race on it.  We only need to ensure that at least one write has
+    // succeeded before we return the pointer into the array.
     VTs[VT.getSimpleVT().SimpleTy] = VT;
-    return &VTs[VT.getSimpleVT().SimpleTy];
+    sys::MemoryFence();
+    return VTs + VT.getSimpleVT().SimpleTy;
   }
 }
 





More information about the llvm-commits mailing list