diff options
author | Owen Anderson <resistor@mac.com> | 2009-08-05 23:16:16 +0000 |
---|---|---|
committer | Owen Anderson <resistor@mac.com> | 2009-08-05 23:16:16 +0000 |
commit | d7f2a6cb3fbc012763adb42fd967f6fefbb22a37 (patch) | |
tree | 0a2846e2b735aa45cedaa4266ffaa62786d07541 /lib/VMCore/Type.cpp | |
parent | 70cd88fb7b5b77f8bbca7417e624d11b6e22a7e7 (diff) | |
download | llvm-d7f2a6cb3fbc012763adb42fd967f6fefbb22a37.tar.gz llvm-d7f2a6cb3fbc012763adb42fd967f6fefbb22a37.tar.bz2 llvm-d7f2a6cb3fbc012763adb42fd967f6fefbb22a37.tar.xz |
Privatize the StructType table, which unfortunately involves routing contexts through a number of APIs.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78258 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Type.cpp')
-rw-r--r-- | lib/VMCore/Type.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/lib/VMCore/Type.cpp b/lib/VMCore/Type.cpp index 61549f8850..ac55096ac8 100644 --- a/lib/VMCore/Type.cpp +++ b/lib/VMCore/Type.cpp @@ -849,22 +849,23 @@ bool VectorType::isValidElementType(const Type *ElemTy) { // Struct Type Factory... // -static ManagedStatic<TypeMap<StructValType, StructType> > StructTypes; - -StructType *StructType::get(const std::vector<const Type*> &ETypes, +StructType *StructType::get(LLVMContext &Context, + const std::vector<const Type*> &ETypes, bool isPacked) { StructValType STV(ETypes, isPacked); StructType *ST = 0; + LLVMContextImpl *pImpl = Context.pImpl; + sys::SmartScopedLock<true> L(*TypeMapLock); - ST = StructTypes->get(STV); + ST = pImpl->StructTypes.get(STV); if (!ST) { // Value not found. Derive a new type! ST = (StructType*) operator new(sizeof(StructType) + sizeof(PATypeHandle) * ETypes.size()); new (ST) StructType(ETypes, isPacked); - StructTypes->add(STV, ST); + pImpl->StructTypes.add(STV, ST); } #ifdef DEBUG_MERGE_TYPES DOUT << "Derived new type: " << *ST << "\n"; @@ -872,7 +873,7 @@ StructType *StructType::get(const std::vector<const Type*> &ETypes, return ST; } -StructType *StructType::get(const Type *type, ...) { +StructType *StructType::get(LLVMContext &Context, const Type *type, ...) { va_list ap; std::vector<const llvm::Type*> StructFields; va_start(ap, type); @@ -880,7 +881,7 @@ StructType *StructType::get(const Type *type, ...) { StructFields.push_back(type); type = va_arg(ap, llvm::Type*); } - return llvm::StructType::get(StructFields); + return llvm::StructType::get(Context, StructFields); } bool StructType::isValidElementType(const Type *ElemTy) { @@ -1146,11 +1147,13 @@ void VectorType::typeBecameConcrete(const DerivedType *AbsTy) { // void StructType::refineAbstractType(const DerivedType *OldType, const Type *NewType) { - StructTypes->RefineAbstractType(this, OldType, NewType); + LLVMContextImpl *pImpl = OldType->getContext().pImpl; + pImpl->StructTypes.RefineAbstractType(this, OldType, NewType); } void StructType::typeBecameConcrete(const DerivedType *AbsTy) { - StructTypes->TypeBecameConcrete(this, AbsTy); + LLVMContextImpl *pImpl = AbsTy->getContext().pImpl; + pImpl->StructTypes.TypeBecameConcrete(this, AbsTy); } // refineAbstractType - Called when a contained type is found to be more |