[llvm-commits] [llvm] r74180 - /llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Owen Anderson
resistor at mac.com
Thu Jun 25 10:09:04 PDT 2009
Author: resistor
Date: Thu Jun 25 12:09:00 2009
New Revision: 74180
URL: http://llvm.org/viewvc/llvm-project?rev=74180&view=rev
Log:
Provide guards for this shared structure. I'm not sure this actually needs
to be shared, but how/where to privatize it is not immediately clear to me.
If any SelectionDAG experts see a better solution, please share!
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=74180&r1=74179&r2=74180&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Thu Jun 25 12:09:00 2009
@@ -31,8 +31,10 @@
#include "llvm/Target/TargetInstrInfo.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/raw_ostream.h"
+#include "llvm/System/Mutex.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallSet.h"
@@ -4977,14 +4979,17 @@
AddNodeIDNode(ID, this);
}
+static ManagedStatic<std::set<MVT, MVT::compareRawBits> > EVTs;
+static MVT VTs[MVT::LAST_VALUETYPE];
+static ManagedStatic<sys::SmartMutex<true> > VTMutex;
+
/// getValueTypeList - Return a pointer to the specified value type.
///
const MVT *SDNode::getValueTypeList(MVT VT) {
+ sys::SmartScopedLock<true> Lock(&*VTMutex);
if (VT.isExtended()) {
- static std::set<MVT, MVT::compareRawBits> EVTs;
- return &(*EVTs.insert(VT).first);
+ return &(*EVTs->insert(VT).first);
} else {
- static MVT VTs[MVT::LAST_VALUETYPE];
VTs[VT.getSimpleVT()] = VT;
return &VTs[VT.getSimpleVT()];
}
More information about the llvm-commits
mailing list