diff --git a/llvm/lib/IR/LLVMContextImpl.h b/llvm/lib/IR/LLVMContextImpl.h --- a/llvm/lib/IR/LLVMContextImpl.h +++ b/llvm/lib/IR/LLVMContextImpl.h @@ -1535,8 +1535,9 @@ DenseMap, ArrayType *> ArrayTypes; DenseMap, VectorType *> VectorTypes; - DenseMap PointerTypes; // Pointers in AddrSpace = 0 - DenseMap, PointerType *> ASPointerTypes; + PointerType *AS0PointerType = nullptr; // AddrSpace = 0 + DenseMap PointerTypes; + DenseMap, PointerType *> LegacyPointerTypes; DenseMap, TypedPointerType *> ASTypedPointerTypes; /// ValueHandles - This map keeps track of all of the value handles that are diff --git a/llvm/lib/IR/Type.cpp b/llvm/lib/IR/Type.cpp --- a/llvm/lib/IR/Type.cpp +++ b/llvm/lib/IR/Type.cpp @@ -748,9 +748,8 @@ if (CImpl->getOpaquePointers()) return get(EltTy->getContext(), AddressSpace); - // Since AddressSpace #0 is the common case, we special case it. - PointerType *&Entry = AddressSpace == 0 ? CImpl->PointerTypes[EltTy] - : CImpl->ASPointerTypes[std::make_pair(EltTy, AddressSpace)]; + PointerType *&Entry = + CImpl->LegacyPointerTypes[std::make_pair(EltTy, AddressSpace)]; if (!Entry) Entry = new (CImpl->Alloc) PointerType(EltTy, AddressSpace); @@ -763,10 +762,8 @@ "Can only create opaque pointers in opaque pointer mode"); // Since AddressSpace #0 is the common case, we special case it. - PointerType *&Entry = - AddressSpace == 0 - ? CImpl->PointerTypes[nullptr] - : CImpl->ASPointerTypes[std::make_pair(nullptr, AddressSpace)]; + PointerType *&Entry = AddressSpace == 0 ? CImpl->AS0PointerType + : CImpl->PointerTypes[AddressSpace]; if (!Entry) Entry = new (CImpl->Alloc) PointerType(C, AddressSpace);