Privatize the FunctionType table.
authorOwen Anderson <resistor@mac.com>
Wed, 5 Aug 2009 18:13:27 +0000 (18:13 +0000)
committerOwen Anderson <resistor@mac.com>
Wed, 5 Aug 2009 18:13:27 +0000 (18:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78221 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 993b155d40974c07e743c58e72ddae92b1597fb3..3ce1234adfa5f309ae2547431dbedf7707ea9288 100644 (file)
@@ -131,6 +131,7 @@ struct LLVMContextImpl {
   TypeMap<ArrayValType, ArrayType> ArrayTypes;
   TypeMap<VectorValType, VectorType> VectorTypes;
   TypeMap<PointerValType, PointerType> PointerTypes;
+  TypeMap<FunctionValType, FunctionType> FunctionTypes;
   
   LLVMContextImpl() : TheTrueVal(0), TheFalseVal(0) { }
 };
index 22d95ed199627dc069b22ca80ae93164999306d4..61549f8850c439e3357c61222d1b6643d4110cf8 100644 (file)
@@ -748,9 +748,6 @@ APInt IntegerType::getMask() const {
   return APInt::getAllOnesValue(getBitWidth());
 }
 
-// Define the actual map itself now...
-static ManagedStatic<TypeMap<FunctionValType, FunctionType> > FunctionTypes;
-
 FunctionValType FunctionValType::get(const FunctionType *FT) {
   // Build up a FunctionValType
   std::vector<const Type *> ParamTypes;
@@ -768,14 +765,16 @@ FunctionType *FunctionType::get(const Type *ReturnType,
   FunctionValType VT(ReturnType, Params, isVarArg);
   FunctionType *FT = 0;
   
+  LLVMContextImpl *pImpl = ReturnType->getContext().pImpl;
+  
   sys::SmartScopedLock<true> L(*TypeMapLock);
-  FT = FunctionTypes->get(VT);
+  FT = pImpl->FunctionTypes.get(VT);
   
   if (!FT) {
     FT = (FunctionType*) operator new(sizeof(FunctionType) +
                                     sizeof(PATypeHandle)*(Params.size()+1));
     new (FT) FunctionType(ReturnType, Params, isVarArg);
-    FunctionTypes->add(VT, FT);
+    pImpl->FunctionTypes.add(VT, FT);
   }
 
 #ifdef DEBUG_MERGE_TYPES
@@ -1101,11 +1100,13 @@ void DerivedType::notifyUsesThatTypeBecameConcrete() {
 //
 void FunctionType::refineAbstractType(const DerivedType *OldType,
                                       const Type *NewType) {
-  FunctionTypes->RefineAbstractType(this, OldType, NewType);
+  LLVMContextImpl *pImpl = OldType->getContext().pImpl;
+  pImpl->FunctionTypes.RefineAbstractType(this, OldType, NewType);
 }
 
 void FunctionType::typeBecameConcrete(const DerivedType *AbsTy) {
-  FunctionTypes->TypeBecameConcrete(this, AbsTy);
+  LLVMContextImpl *pImpl = AbsTy->getContext().pImpl;
+  pImpl->FunctionTypes.TypeBecameConcrete(this, AbsTy);
 }