[PATCH] D52268: [AST] Squeeze some bits in LinkageComputer
Bruno Ricci via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Sep 19 08:49:24 PDT 2018
riccibruno created this revision.
riccibruno added reviewers: erichkeane, rjmccall.
riccibruno added a project: clang.
Herald added a subscriber: cfe-commits.
Since Decls are already aligned explicitly to 8 bytes, stash the
3 bits representing an LVComputationKind into the lower 3 bits
of the NamedDecl * in LinkageComputer.
Repository:
rC Clang
https://reviews.llvm.org/D52268
Files:
lib/AST/Linkage.h
Index: lib/AST/Linkage.h
===================================================================
--- lib/AST/Linkage.h
+++ 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 @@
/// in computing linkage.
unsigned IgnoreAllVisibility : 1;
+ enum { NumLVComputationKindBits = 3 };
+
explicit LVComputationKind(NamedDecl::ExplicitVisibilityKind EK)
: ExplicitKind(EK), IgnoreExplicitVisibility(false),
IgnoreAllVisibility(false) {}
@@ -78,12 +81,16 @@
// 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_assert(alignof(NamedDecl) >= 8,
+ "LinkageComputer assumes that NamedDecl is aligned to >= 8!");
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,
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52268.166137.patch
Type: text/x-patch
Size: 1488 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180919/3109d2df/attachment.bin>
More information about the cfe-commits
mailing list