Privatize the VectorType uniquing.
authorOwen Anderson <resistor@mac.com>
Tue, 4 Aug 2009 23:47:44 +0000 (23:47 +0000)
committerOwen Anderson <resistor@mac.com>
Tue, 4 Aug 2009 23:47:44 +0000 (23:47 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78125 91177308-0d34-0410-b5e6-96231b3b80d8

lib/VMCore/LLVMContextImpl.h
lib/VMCore/Type.cpp

index 5e027cb907fd9256cc4de52802890380b6f81c40..a92b571f699d9f630d7b8c7dbff75c6c44c75a11 100644 (file)
@@ -129,6 +129,7 @@ struct LLVMContextImpl {
   ConstantInt *TheFalseVal;
   
   TypeMap<ArrayValType, ArrayType> ArrayTypes;
+  TypeMap<VectorValType, VectorType> VectorTypes;
   
   LLVMContextImpl() : TheTrueVal(0), TheFalseVal(0) { }
 };
index 3c1a67f3a1c90e26a57e1304453db8e608ce409a..610036ef0d57a2b49b506a71b9c99cf804156af1 100644 (file)
@@ -818,19 +818,19 @@ bool ArrayType::isValidElementType(const Type *ElemTy) {
   return true;
 }
 
-static ManagedStatic<TypeMap<VectorValType, VectorType> > VectorTypes;
-
 VectorType *VectorType::get(const Type *ElementType, unsigned NumElements) {
   assert(ElementType && "Can't get vector of <null> types!");
 
   VectorValType PVT(ElementType, NumElements);
   VectorType *PT = 0;
   
+  LLVMContextImpl *pImpl = ElementType->getContext().pImpl;
+  
   sys::SmartScopedLock<true> L(*TypeMapLock);
-  PT = VectorTypes->get(PVT);
+  PT = pImpl->VectorTypes.get(PVT);
     
   if (!PT) {
-    VectorTypes->add(PVT, PT = new VectorType(ElementType, NumElements));
+    pImpl->VectorTypes.add(PVT, PT = new VectorType(ElementType, NumElements));
   }
 #ifdef DEBUG_MERGE_TYPES
   DOUT << "Derived new type: " << *PT << "\n";
@@ -1130,11 +1130,13 @@ void ArrayType::typeBecameConcrete(const DerivedType *AbsTy) {
 //
 void VectorType::refineAbstractType(const DerivedType *OldType,
                                    const Type *NewType) {
-  VectorTypes->RefineAbstractType(this, OldType, NewType);
+  LLVMContextImpl *pImpl = OldType->getContext().pImpl;
+  pImpl->VectorTypes.RefineAbstractType(this, OldType, NewType);
 }
 
 void VectorType::typeBecameConcrete(const DerivedType *AbsTy) {
-  VectorTypes->TypeBecameConcrete(this, AbsTy);
+  LLVMContextImpl *pImpl = AbsTy->getContext().pImpl;
+  pImpl->VectorTypes.TypeBecameConcrete(this, AbsTy);
 }
 
 // refineAbstractType - Called when a contained type is found to be more