aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2009-08-22 06:32:36 +0000
committerOwen Anderson <resistor@mac.com>2009-08-22 06:32:36 +0000
commit1a285c21708d469a799ba3d59292b8d23a137bb9 (patch)
tree4ec967737d019fed05a37c8516f3c62a78cdf720
parent7c50243ed8beecd41637df8c224e1fe0d0f7f342 (diff)
downloadexternal_llvm-1a285c21708d469a799ba3d59292b8d23a137bb9.zip
external_llvm-1a285c21708d469a799ba3d59292b8d23a137bb9.tar.gz
external_llvm-1a285c21708d469a799ba3d59292b8d23a137bb9.tar.bz2
Reapply r79708 with the appropriate fix for the case that still requires locking.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79731 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAG.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 72f2112..6ce30f6 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -5022,12 +5022,16 @@ static ManagedStatic<sys::SmartMutex<true> > VTMutex;
/// 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;
}
}