summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBruno Ricci <riccibrun@gmail.com>2018-09-25 13:43:25 +0000
committerBruno Ricci <riccibrun@gmail.com>2018-09-25 13:43:25 +0000
commitcf86ce0a7a954dc939711da585ceb6321e1b666b (patch)
treefaee71b4da42c03493cc2a0b150b837de9fac813
parent9bc3bfffb483e24cb665a6c65f846a81e4caa31a (diff)
downloadbcm5719-llvm-cf86ce0a7a954dc939711da585ceb6321e1b666b.tar.gz
bcm5719-llvm-cf86ce0a7a954dc939711da585ceb6321e1b666b.zip
[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 llvm-svn: 342973
-rw-r--r--clang/lib/AST/Linkage.h11
1 files changed, 8 insertions, 3 deletions
diff --git a/clang/lib/AST/Linkage.h b/clang/lib/AST/Linkage.h
index e6489c7ef2b..8ad748bcc4a 100644
--- a/clang/lib/AST/Linkage.h
+++ b/clang/lib/AST/Linkage.h
@@ -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,
OpenPOWER on IntegriCloud