DenseSet has better memory efficiency now.
llvm-svn: 223589
static bool isEqual(const StructType *LHS, const StructType *RHS);
};
- typedef DenseMap<StructType *, bool, StructTypeKeyInfo>
- NonOpaqueStructTypeSet;
+ typedef DenseSet<StructType *, StructTypeKeyInfo> NonOpaqueStructTypeSet;
typedef DenseSet<StructType *> OpaqueStructTypeSet;
struct IdentifiedStructTypeSet {
BumpPtrAllocator TypeAllocator;
DenseMap<unsigned, IntegerType*> IntegerTypes;
-
- typedef DenseMap<FunctionType*, bool, FunctionTypeKeyInfo> FunctionTypeMap;
- FunctionTypeMap FunctionTypes;
- typedef DenseMap<StructType*, bool, AnonStructTypeKeyInfo> StructTypeMap;
- StructTypeMap AnonStructTypes;
+
+ typedef DenseSet<FunctionType *, FunctionTypeKeyInfo> FunctionTypeSet;
+ FunctionTypeSet FunctionTypes;
+ typedef DenseSet<StructType *, AnonStructTypeKeyInfo> StructTypeSet;
+ StructTypeSet AnonStructTypes;
StringMap<StructType*> NamedStructTypes;
unsigned NamedStructTypesUniqueID;
ArrayRef<Type*> Params, bool isVarArg) {
LLVMContextImpl *pImpl = ReturnType->getContext().pImpl;
FunctionTypeKeyInfo::KeyTy Key(ReturnType, Params, isVarArg);
- LLVMContextImpl::FunctionTypeMap::iterator I =
- pImpl->FunctionTypes.find_as(Key);
+ auto I = pImpl->FunctionTypes.find_as(Key);
FunctionType *FT;
if (I == pImpl->FunctionTypes.end()) {
Allocate(sizeof(FunctionType) + sizeof(Type*) * (Params.size() + 1),
AlignOf<FunctionType>::Alignment);
new (FT) FunctionType(ReturnType, Params, isVarArg);
- pImpl->FunctionTypes[FT] = true;
+ pImpl->FunctionTypes.insert(FT);
} else {
- FT = I->first;
+ FT = *I;
}
return FT;
bool isPacked) {
LLVMContextImpl *pImpl = Context.pImpl;
AnonStructTypeKeyInfo::KeyTy Key(ETypes, isPacked);
- LLVMContextImpl::StructTypeMap::iterator I =
- pImpl->AnonStructTypes.find_as(Key);
+ auto I = pImpl->AnonStructTypes.find_as(Key);
StructType *ST;
if (I == pImpl->AnonStructTypes.end()) {
ST = new (Context.pImpl->TypeAllocator) StructType(Context);
ST->setSubclassData(SCDB_IsLiteral); // Literal struct.
ST->setBody(ETypes, isPacked);
- Context.pImpl->AnonStructTypes[ST] = true;
+ Context.pImpl->AnonStructTypes.insert(ST);
} else {
- ST = I->first;
+ ST = *I;
}
return ST;
void Linker::IdentifiedStructTypeSet::addNonOpaque(StructType *Ty) {
assert(!Ty->isOpaque());
- bool &Entry = NonOpaqueStructTypes[Ty];
- Entry = true;
+ NonOpaqueStructTypes.insert(Ty);
}
void Linker::IdentifiedStructTypeSet::addOpaque(StructType *Ty) {
auto I = NonOpaqueStructTypes.find_as(Key);
if (I == NonOpaqueStructTypes.end())
return nullptr;
- return I->first;
+ return *I;
}
bool Linker::IdentifiedStructTypeSet::hasType(StructType *Ty) {
auto I = NonOpaqueStructTypes.find(Ty);
if (I == NonOpaqueStructTypes.end())
return false;
- return I->first == Ty;
+ return *I == Ty;
}
void Linker::init(Module *M, DiagnosticHandlerFunction DiagnosticHandler) {