[llvm] r223589 - Turn some DenseMaps that are only used for set operations into DenseSets.
Rafael EspĂndola
rafael.espindola at gmail.com
Thu Dec 11 06:45:57 PST 2014
Thanks!
On 6 December 2014 at 14:22, Benjamin Kramer <benny.kra at googlemail.com> wrote:
> Author: d0k
> Date: Sat Dec 6 13:22:54 2014
> New Revision: 223589
>
> URL: http://llvm.org/viewvc/llvm-project?rev=223589&view=rev
> Log:
> Turn some DenseMaps that are only used for set operations into DenseSets.
>
> DenseSet has better memory efficiency now.
>
> Modified:
> llvm/trunk/include/llvm/Linker/Linker.h
> llvm/trunk/lib/IR/LLVMContextImpl.h
> llvm/trunk/lib/IR/Type.cpp
> llvm/trunk/lib/Linker/LinkModules.cpp
>
> Modified: llvm/trunk/include/llvm/Linker/Linker.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Linker/Linker.h?rev=223589&r1=223588&r2=223589&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Linker/Linker.h (original)
> +++ llvm/trunk/include/llvm/Linker/Linker.h Sat Dec 6 13:22:54 2014
> @@ -47,8 +47,7 @@ public:
> 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 {
>
> Modified: llvm/trunk/lib/IR/LLVMContextImpl.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/LLVMContextImpl.h?rev=223589&r1=223588&r2=223589&view=diff
> ==============================================================================
> --- llvm/trunk/lib/IR/LLVMContextImpl.h (original)
> +++ llvm/trunk/lib/IR/LLVMContextImpl.h Sat Dec 6 13:22:54 2014
> @@ -313,11 +313,11 @@ public:
> 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;
>
>
> Modified: llvm/trunk/lib/IR/Type.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Type.cpp?rev=223589&r1=223588&r2=223589&view=diff
> ==============================================================================
> --- llvm/trunk/lib/IR/Type.cpp (original)
> +++ llvm/trunk/lib/IR/Type.cpp Sat Dec 6 13:22:54 2014
> @@ -360,8 +360,7 @@ FunctionType *FunctionType::get(Type *Re
> 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()) {
> @@ -369,9 +368,9 @@ FunctionType *FunctionType::get(Type *Re
> 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;
> @@ -404,8 +403,7 @@ StructType *StructType::get(LLVMContext
> 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()) {
> @@ -413,9 +411,9 @@ StructType *StructType::get(LLVMContext
> 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;
>
> Modified: llvm/trunk/lib/Linker/LinkModules.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=223589&r1=223588&r2=223589&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Linker/LinkModules.cpp (original)
> +++ llvm/trunk/lib/Linker/LinkModules.cpp Sat Dec 6 13:22:54 2014
> @@ -1593,8 +1593,7 @@ bool Linker::StructTypeKeyInfo::isEqual(
>
> void Linker::IdentifiedStructTypeSet::addNonOpaque(StructType *Ty) {
> assert(!Ty->isOpaque());
> - bool &Entry = NonOpaqueStructTypes[Ty];
> - Entry = true;
> + NonOpaqueStructTypes.insert(Ty);
> }
>
> void Linker::IdentifiedStructTypeSet::addOpaque(StructType *Ty) {
> @@ -1609,7 +1608,7 @@ Linker::IdentifiedStructTypeSet::findNon
> auto I = NonOpaqueStructTypes.find_as(Key);
> if (I == NonOpaqueStructTypes.end())
> return nullptr;
> - return I->first;
> + return *I;
> }
>
> bool Linker::IdentifiedStructTypeSet::hasType(StructType *Ty) {
> @@ -1618,7 +1617,7 @@ bool Linker::IdentifiedStructTypeSet::ha
> 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) {
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list