Privatize the PointerType factory.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78130 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Owen Anderson 2009-08-05 00:15:12 +00:00
parent e55fef36a9
commit 84e99f3c25
2 changed files with 9 additions and 6 deletions

View File

@ -130,6 +130,7 @@ struct LLVMContextImpl {
TypeMap<ArrayValType, ArrayType> ArrayTypes;
TypeMap<VectorValType, VectorType> VectorTypes;
TypeMap<PointerValType, PointerType> PointerTypes;
LLVMContextImpl() : TheTrueVal(0), TheFalseVal(0) { }
};

View File

@ -901,8 +901,6 @@ bool StructType::isValidElementType(const Type *ElemTy) {
// 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 *PointerType::get(const Type *ValueType, unsigned AddressSpace) {
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 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 {