mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 11:42:57 +01:00
Move the TypeMap lock to a member on LLVMContextImpl.
llvm-svn: 79256
This commit is contained in:
parent
43d358bde0
commit
5d27af4989
@ -20,6 +20,7 @@
|
|||||||
#include "llvm/LLVMContext.h"
|
#include "llvm/LLVMContext.h"
|
||||||
#include "llvm/Constants.h"
|
#include "llvm/Constants.h"
|
||||||
#include "llvm/DerivedTypes.h"
|
#include "llvm/DerivedTypes.h"
|
||||||
|
#include "llvm/System/Mutex.h"
|
||||||
#include "llvm/System/RWMutex.h"
|
#include "llvm/System/RWMutex.h"
|
||||||
#include "llvm/ADT/APFloat.h"
|
#include "llvm/ADT/APFloat.h"
|
||||||
#include "llvm/ADT/APInt.h"
|
#include "llvm/ADT/APInt.h"
|
||||||
@ -132,6 +133,9 @@ public:
|
|||||||
ConstantInt *TheTrueVal;
|
ConstantInt *TheTrueVal;
|
||||||
ConstantInt *TheFalseVal;
|
ConstantInt *TheFalseVal;
|
||||||
|
|
||||||
|
// Lock used for guarding access to the type maps.
|
||||||
|
sys::SmartMutex<true> TypeMapLock;
|
||||||
|
|
||||||
TypeMap<ArrayValType, ArrayType> ArrayTypes;
|
TypeMap<ArrayValType, ArrayType> ArrayTypes;
|
||||||
TypeMap<VectorValType, VectorType> VectorTypes;
|
TypeMap<VectorValType, VectorType> VectorTypes;
|
||||||
TypeMap<PointerValType, PointerType> PointerTypes;
|
TypeMap<PointerValType, PointerType> PointerTypes;
|
||||||
|
@ -47,9 +47,6 @@ AbstractTypeUser::~AbstractTypeUser() {}
|
|||||||
// Type Class Implementation
|
// 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.
|
// Recursive lock used for guarding access to AbstractTypeUsers.
|
||||||
// NOTE: The true template parameter means this will no-op when we're not in
|
// NOTE: The true template parameter means this will no-op when we're not in
|
||||||
// multithreaded mode.
|
// multithreaded mode.
|
||||||
@ -759,7 +756,7 @@ const IntegerType *IntegerType::get(LLVMContext &C, unsigned NumBits) {
|
|||||||
|
|
||||||
// First, see if the type is already in the table, for which
|
// First, see if the type is already in the table, for which
|
||||||
// a reader lock suffices.
|
// a reader lock suffices.
|
||||||
sys::SmartScopedLock<true> L(*TypeMapLock);
|
sys::SmartScopedLock<true> L(pImpl->TypeMapLock);
|
||||||
ITy = pImpl->IntegerTypes.get(IVT);
|
ITy = pImpl->IntegerTypes.get(IVT);
|
||||||
|
|
||||||
if (!ITy) {
|
if (!ITy) {
|
||||||
@ -801,7 +798,7 @@ FunctionType *FunctionType::get(const Type *ReturnType,
|
|||||||
|
|
||||||
LLVMContextImpl *pImpl = ReturnType->getContext().pImpl;
|
LLVMContextImpl *pImpl = ReturnType->getContext().pImpl;
|
||||||
|
|
||||||
sys::SmartScopedLock<true> L(*TypeMapLock);
|
sys::SmartScopedLock<true> L(pImpl->TypeMapLock);
|
||||||
FT = pImpl->FunctionTypes.get(VT);
|
FT = pImpl->FunctionTypes.get(VT);
|
||||||
|
|
||||||
if (!FT) {
|
if (!FT) {
|
||||||
@ -826,7 +823,7 @@ ArrayType *ArrayType::get(const Type *ElementType, uint64_t NumElements) {
|
|||||||
|
|
||||||
LLVMContextImpl *pImpl = ElementType->getContext().pImpl;
|
LLVMContextImpl *pImpl = ElementType->getContext().pImpl;
|
||||||
|
|
||||||
sys::SmartScopedLock<true> L(*TypeMapLock);
|
sys::SmartScopedLock<true> L(pImpl->TypeMapLock);
|
||||||
AT = pImpl->ArrayTypes.get(AVT);
|
AT = pImpl->ArrayTypes.get(AVT);
|
||||||
|
|
||||||
if (!AT) {
|
if (!AT) {
|
||||||
@ -860,7 +857,7 @@ VectorType *VectorType::get(const Type *ElementType, unsigned NumElements) {
|
|||||||
|
|
||||||
LLVMContextImpl *pImpl = ElementType->getContext().pImpl;
|
LLVMContextImpl *pImpl = ElementType->getContext().pImpl;
|
||||||
|
|
||||||
sys::SmartScopedLock<true> L(*TypeMapLock);
|
sys::SmartScopedLock<true> L(pImpl->TypeMapLock);
|
||||||
PT = pImpl->VectorTypes.get(PVT);
|
PT = pImpl->VectorTypes.get(PVT);
|
||||||
|
|
||||||
if (!PT) {
|
if (!PT) {
|
||||||
@ -892,7 +889,7 @@ StructType *StructType::get(LLVMContext &Context,
|
|||||||
|
|
||||||
LLVMContextImpl *pImpl = Context.pImpl;
|
LLVMContextImpl *pImpl = Context.pImpl;
|
||||||
|
|
||||||
sys::SmartScopedLock<true> L(*TypeMapLock);
|
sys::SmartScopedLock<true> L(pImpl->TypeMapLock);
|
||||||
ST = pImpl->StructTypes.get(STV);
|
ST = pImpl->StructTypes.get(STV);
|
||||||
|
|
||||||
if (!ST) {
|
if (!ST) {
|
||||||
@ -948,7 +945,7 @@ PointerType *PointerType::get(const Type *ValueType, unsigned AddressSpace) {
|
|||||||
|
|
||||||
LLVMContextImpl *pImpl = ValueType->getContext().pImpl;
|
LLVMContextImpl *pImpl = ValueType->getContext().pImpl;
|
||||||
|
|
||||||
sys::SmartScopedLock<true> L(*TypeMapLock);
|
sys::SmartScopedLock<true> L(pImpl->TypeMapLock);
|
||||||
PT = pImpl->PointerTypes.get(PVT);
|
PT = pImpl->PointerTypes.get(PVT);
|
||||||
|
|
||||||
if (!PT) {
|
if (!PT) {
|
||||||
@ -1108,7 +1105,7 @@ void DerivedType::unlockedRefineAbstractTypeTo(const Type *NewType) {
|
|||||||
void DerivedType::refineAbstractTypeTo(const Type *NewType) {
|
void DerivedType::refineAbstractTypeTo(const Type *NewType) {
|
||||||
// All recursive calls will go through unlockedRefineAbstractTypeTo,
|
// All recursive calls will go through unlockedRefineAbstractTypeTo,
|
||||||
// to avoid deadlock problems.
|
// to avoid deadlock problems.
|
||||||
sys::SmartScopedLock<true> L(*TypeMapLock);
|
sys::SmartScopedLock<true> L(NewType->getContext().pImpl->TypeMapLock);
|
||||||
unlockedRefineAbstractTypeTo(NewType);
|
unlockedRefineAbstractTypeTo(NewType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user