From 84e99f3c2543eb47262a0e79b04a3834bc50a468 Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Wed, 5 Aug 2009 00:15:12 +0000 Subject: [PATCH] Privatize the PointerType factory. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78130 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/LLVMContextImpl.h | 1 + lib/VMCore/Type.cpp | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/VMCore/LLVMContextImpl.h b/lib/VMCore/LLVMContextImpl.h index a92b571f699..993b155d409 100644 --- a/lib/VMCore/LLVMContextImpl.h +++ b/lib/VMCore/LLVMContextImpl.h @@ -130,6 +130,7 @@ struct LLVMContextImpl { TypeMap ArrayTypes; TypeMap VectorTypes; + TypeMap PointerTypes; LLVMContextImpl() : TheTrueVal(0), TheFalseVal(0) { } }; diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index 610036ef0d5..22d95ed1996 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -901,8 +901,6 @@ bool StructType::isValidElementType(const Type *ElemTy) { // Pointer Type Factory... // -static ManagedStatic > PointerTypes; - PointerType *PointerType::get(const Type *ValueType, unsigned AddressSpace) { assert(ValueType && "Can't get a pointer to type!"); assert(ValueType != Type::VoidTy && @@ -912,12 +910,14 @@ PointerType *PointerType::get(const Type *ValueType, unsigned AddressSpace) { PointerType *PT = 0; + LLVMContextImpl *pImpl = ValueType->getContext().pImpl; + sys::SmartScopedLock L(*TypeMapLock); - PT = PointerTypes->get(PVT); + PT = pImpl->PointerTypes.get(PVT); if (!PT) { // Value not found. Derive a new type! - PointerTypes->add(PVT, PT = new PointerType(ValueType, AddressSpace)); + pImpl->PointerTypes.add(PVT, PT = new PointerType(ValueType, AddressSpace)); } #ifdef DEBUG_MERGE_TYPES DOUT << "Derived new type: " << *PT << "\n"; @@ -1158,11 +1158,13 @@ void StructType::typeBecameConcrete(const DerivedType *AbsTy) { // void PointerType::refineAbstractType(const DerivedType *OldType, const Type *NewType) { - PointerTypes->RefineAbstractType(this, OldType, NewType); + LLVMContextImpl *pImpl = OldType->getContext().pImpl; + pImpl->PointerTypes.RefineAbstractType(this, OldType, NewType); } void PointerType::typeBecameConcrete(const DerivedType *AbsTy) { - PointerTypes->TypeBecameConcrete(this, AbsTy); + LLVMContextImpl *pImpl = AbsTy->getContext().pImpl; + pImpl->PointerTypes.TypeBecameConcrete(this, AbsTy); } bool SequentialType::indexValid(const Value *V) const { -- 2.34.1