[llvm-commits] [llvm] r78130 - in /llvm/trunk/lib/VMCore: LLVMContextImpl.h Type.cpp

Owen Anderson resistor at mac.com
Tue Aug 4 17:15:12 PDT 2009


Author: resistor
Date: Tue Aug  4 19:15:12 2009
New Revision: 78130

URL: http://llvm.org/viewvc/llvm-project?rev=78130&view=rev
Log:
Privatize the PointerType factory.

Modified:
    llvm/trunk/lib/VMCore/LLVMContextImpl.h
    llvm/trunk/lib/VMCore/Type.cpp

Modified: llvm/trunk/lib/VMCore/LLVMContextImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/LLVMContextImpl.h?rev=78130&r1=78129&r2=78130&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/LLVMContextImpl.h (original)
+++ llvm/trunk/lib/VMCore/LLVMContextImpl.h Tue Aug  4 19:15:12 2009
@@ -130,6 +130,7 @@
   
   TypeMap<ArrayValType, ArrayType> ArrayTypes;
   TypeMap<VectorValType, VectorType> VectorTypes;
+  TypeMap<PointerValType, PointerType> PointerTypes;
   
   LLVMContextImpl() : TheTrueVal(0), TheFalseVal(0) { }
 };

Modified: llvm/trunk/lib/VMCore/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Type.cpp?rev=78130&r1=78129&r2=78130&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/Type.cpp (original)
+++ llvm/trunk/lib/VMCore/Type.cpp Tue Aug  4 19:15:12 2009
@@ -901,8 +901,6 @@
 // Pointer Type Factory...
 //
 
-static ManagedStatic<TypeMap<PointerValType, PointerType> > PointerTypes;
-
 PointerType *PointerType::get(const Type *ValueType, unsigned AddressSpace) {
   assert(ValueType && "Can't get a pointer to <null> type!");
   assert(ValueType != Type::VoidTy &&
@@ -912,12 +910,14 @@
 
   PointerType *PT = 0;
   
+  LLVMContextImpl *pImpl = ValueType->getContext().pImpl;
+  
   sys::SmartScopedLock<true> 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 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 {





More information about the llvm-commits mailing list