#include "llvm/LLVMContext.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
+#include "llvm/System/Mutex.h"
#include "llvm/System/RWMutex.h"
#include "llvm/ADT/APFloat.h"
#include "llvm/ADT/APInt.h"
ConstantInt *TheTrueVal;
ConstantInt *TheFalseVal;
+ // Lock used for guarding access to the type maps.
+ sys::SmartMutex<true> TypeMapLock;
+
TypeMap<ArrayValType, ArrayType> ArrayTypes;
TypeMap<VectorValType, VectorType> VectorTypes;
TypeMap<PointerValType, PointerType> PointerTypes;
// Type Class Implementation
//===----------------------------------------------------------------------===//
-// Lock used for guarding access to the type maps.
-static ManagedStatic<sys::SmartMutex<true> > TypeMapLock;
-
// Recursive lock used for guarding access to AbstractTypeUsers.
// NOTE: The true template parameter means this will no-op when we're not in
// multithreaded mode.
// First, see if the type is already in the table, for which
// a reader lock suffices.
- sys::SmartScopedLock<true> L(*TypeMapLock);
+ sys::SmartScopedLock<true> L(pImpl->TypeMapLock);
ITy = pImpl->IntegerTypes.get(IVT);
if (!ITy) {
LLVMContextImpl *pImpl = ReturnType->getContext().pImpl;
- sys::SmartScopedLock<true> L(*TypeMapLock);
+ sys::SmartScopedLock<true> L(pImpl->TypeMapLock);
FT = pImpl->FunctionTypes.get(VT);
if (!FT) {
LLVMContextImpl *pImpl = ElementType->getContext().pImpl;
- sys::SmartScopedLock<true> L(*TypeMapLock);
+ sys::SmartScopedLock<true> L(pImpl->TypeMapLock);
AT = pImpl->ArrayTypes.get(AVT);
if (!AT) {
LLVMContextImpl *pImpl = ElementType->getContext().pImpl;
- sys::SmartScopedLock<true> L(*TypeMapLock);
+ sys::SmartScopedLock<true> L(pImpl->TypeMapLock);
PT = pImpl->VectorTypes.get(PVT);
if (!PT) {
LLVMContextImpl *pImpl = Context.pImpl;
- sys::SmartScopedLock<true> L(*TypeMapLock);
+ sys::SmartScopedLock<true> L(pImpl->TypeMapLock);
ST = pImpl->StructTypes.get(STV);
if (!ST) {
LLVMContextImpl *pImpl = ValueType->getContext().pImpl;
- sys::SmartScopedLock<true> L(*TypeMapLock);
+ sys::SmartScopedLock<true> L(pImpl->TypeMapLock);
PT = pImpl->PointerTypes.get(PVT);
if (!PT) {
void DerivedType::refineAbstractTypeTo(const Type *NewType) {
// All recursive calls will go through unlockedRefineAbstractTypeTo,
// to avoid deadlock problems.
- sys::SmartScopedLock<true> L(*TypeMapLock);
+ sys::SmartScopedLock<true> L(NewType->getContext().pImpl->TypeMapLock);
unlockedRefineAbstractTypeTo(NewType);
}