Author: brunoricci Date: Tue Sep 25 06:43:25 2018 New Revision: 342973 URL: http://llvm.org/viewvc/llvm-project?rev=342973&view=rev Log: [AST] Squeeze some bits in LinkageComputer::QueryType
Replace the pair std::pair<const NamedDecl *, unsigned> where the unsigned represents an LVComputationKind by a PointerIntPair. This saves a pointer per entry in the map LinkageComputer::CachedLinkageInfo. Differential Revision: https://reviews.llvm.org/D52268 Reviewed by: rjmccall, george.burgess.iv, erichkeane Modified: cfe/trunk/lib/AST/Linkage.h Modified: cfe/trunk/lib/AST/Linkage.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Linkage.h?rev=342973&r1=342972&r2=342973&view=diff ============================================================================== --- cfe/trunk/lib/AST/Linkage.h (original) +++ cfe/trunk/lib/AST/Linkage.h Tue Sep 25 06:43:25 2018 @@ -20,6 +20,7 @@ #include "clang/AST/Type.h" #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/Optional.h" +#include "llvm/ADT/PointerIntPair.h" namespace clang { /// Kinds of LV computation. The linkage side of the computation is @@ -36,6 +37,8 @@ struct LVComputationKind { /// in computing linkage. unsigned IgnoreAllVisibility : 1; + enum { NumLVComputationKindBits = 3 }; + explicit LVComputationKind(NamedDecl::ExplicitVisibilityKind EK) : ExplicitKind(EK), IgnoreExplicitVisibility(false), IgnoreAllVisibility(false) {} @@ -78,12 +81,14 @@ class LinkageComputer { // using C = Foo<B, B>; // using D = Foo<C, C>; // - // The unsigned represents an LVComputationKind. - using QueryType = std::pair<const NamedDecl *, unsigned>; + // The integer represents an LVComputationKind. + using QueryType = + llvm::PointerIntPair<const NamedDecl *, + LVComputationKind::NumLVComputationKindBits>; llvm::SmallDenseMap<QueryType, LinkageInfo, 8> CachedLinkageInfo; static QueryType makeCacheKey(const NamedDecl *ND, LVComputationKind Kind) { - return std::make_pair(ND, Kind.toBits()); + return QueryType(ND, Kind.toBits()); } llvm::Optional<LinkageInfo> lookup(const NamedDecl *ND, _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits