<div dir="ltr">This change has broken a number of buildbots, e.g. <a href="http://lab.llvm.org:8011/builders/sanitizer-windows/builds/23163">http://lab.llvm.org:8011/builders/sanitizer-windows/builds/23163</a></div><br><div class="gmail_quote"><div dir="ltr">On Fri, Jan 26, 2018 at 6:15 AM Benjamin Kramer via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: d0k<br>
Date: Fri Jan 26 06:14:11 2018<br>
New Revision: 323528<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=323528&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=323528&view=rev</a><br>
Log:<br>
[AST] Use bit packing to reduce sizeof(TypedefNameDecl) from 88 to 80.<br>
<br>
We can stash the cached transparent tag bit in existing pointer padding.<br>
Everything coming out of ASTContext is always aligned to a multiple of<br>
8, so we have 8 spare bits.<br>
<br>
Modified:<br>
cfe/trunk/include/clang/AST/Decl.h<br>
cfe/trunk/lib/AST/Decl.cpp<br>
<br>
Modified: cfe/trunk/include/clang/AST/Decl.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=323528&r1=323527&r2=323528&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=323528&r1=323527&r2=323528&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/AST/Decl.h (original)<br>
+++ cfe/trunk/include/clang/AST/Decl.h Fri Jan 26 06:14:11 2018<br>
@@ -2814,12 +2814,12 @@ public:<br>
/// Base class for declarations which introduce a typedef-name.<br>
class TypedefNameDecl : public TypeDecl, public Redeclarable<TypedefNameDecl> {<br>
using ModedTInfo = std::pair<TypeSourceInfo *, QualType>;<br>
- llvm::PointerUnion<TypeSourceInfo *, ModedTInfo *> MaybeModedTInfo;<br>
<br>
- // FIXME: This can be packed into the bitfields in Decl.<br>
- /// If 0, we have not computed IsTransparentTag.<br>
- /// Otherwise, IsTransparentTag is (CacheIsTransparentTag >> 1).<br>
- mutable unsigned CacheIsTransparentTag : 2;<br>
+ /// If int part is 0, we have not computed IsTransparentTag.<br>
+ /// Otherwise, IsTransparentTag is (getInt() >> 1).<br>
+ mutable llvm::PointerIntPair<<br>
+ llvm::PointerUnion<TypeSourceInfo *, ModedTInfo *>, 2><br>
+ MaybeModedTInfo;<br>
<br>
void anchor() override;<br>
<br>
@@ -2828,7 +2828,7 @@ protected:<br>
SourceLocation StartLoc, SourceLocation IdLoc,<br>
IdentifierInfo *Id, TypeSourceInfo *TInfo)<br>
: TypeDecl(DK, DC, IdLoc, Id, StartLoc), redeclarable_base(C),<br>
- MaybeModedTInfo(TInfo), CacheIsTransparentTag(0) {}<br>
+ MaybeModedTInfo(TInfo, 0) {}<br>
<br>
using redeclarable_base = Redeclarable<TypedefNameDecl>;<br>
<br>
@@ -2855,26 +2855,29 @@ public:<br>
using redeclarable_base::getMostRecentDecl;<br>
using redeclarable_base::isFirstDecl;<br>
<br>
- bool isModed() const { return MaybeModedTInfo.is<ModedTInfo*>(); }<br>
+ bool isModed() const {<br>
+ return MaybeModedTInfo.getPointer().is<ModedTInfo *>();<br>
+ }<br>
<br>
TypeSourceInfo *getTypeSourceInfo() const {<br>
- return isModed()<br>
- ? MaybeModedTInfo.get<ModedTInfo*>()->first<br>
- : MaybeModedTInfo.get<TypeSourceInfo*>();<br>
+ return isModed() ? MaybeModedTInfo.getPointer().get<ModedTInfo *>()->first<br>
+ : MaybeModedTInfo.getPointer().get<TypeSourceInfo *>();<br>
}<br>
<br>
QualType getUnderlyingType() const {<br>
- return isModed()<br>
- ? MaybeModedTInfo.get<ModedTInfo*>()->second<br>
- : MaybeModedTInfo.get<TypeSourceInfo*>()->getType();<br>
+ return isModed() ? MaybeModedTInfo.getPointer().get<ModedTInfo *>()->second<br>
+ : MaybeModedTInfo.getPointer()<br>
+ .get<TypeSourceInfo *>()<br>
+ ->getType();<br>
}<br>
<br>
void setTypeSourceInfo(TypeSourceInfo *newType) {<br>
- MaybeModedTInfo = newType;<br>
+ MaybeModedTInfo.setPointer(newType);<br>
}<br>
<br>
void setModedTypeSourceInfo(TypeSourceInfo *unmodedTSI, QualType modedTy) {<br>
- MaybeModedTInfo = new (getASTContext()) ModedTInfo(unmodedTSI, modedTy);<br>
+ MaybeModedTInfo.setPointer(new (getASTContext(), 8)<br>
+ ModedTInfo(unmodedTSI, modedTy));<br>
}<br>
<br>
/// Retrieves the canonical declaration of this typedef-name.<br>
@@ -2891,8 +2894,8 @@ public:<br>
/// Determines if this typedef shares a name and spelling location with its<br>
/// underlying tag type, as is the case with the NS_ENUM macro.<br>
bool isTransparentTag() const {<br>
- if (CacheIsTransparentTag)<br>
- return CacheIsTransparentTag & 0x2;<br>
+ if (MaybeModedTInfo.getInt())<br>
+ return MaybeModedTInfo.getInt() & 0x2;<br>
return isTransparentTagSlow();<br>
}<br>
<br>
<br>
Modified: cfe/trunk/lib/AST/Decl.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=323528&r1=323527&r2=323528&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=323528&r1=323527&r2=323528&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/AST/Decl.cpp (original)<br>
+++ cfe/trunk/lib/AST/Decl.cpp Fri Jan 26 06:14:11 2018<br>
@@ -4372,9 +4372,7 @@ bool TypedefNameDecl::isTransparentTagSl<br>
};<br>
<br>
bool isTransparent = determineIsTransparent();<br>
- CacheIsTransparentTag = 1;<br>
- if (isTransparent)<br>
- CacheIsTransparentTag |= 0x2;<br>
+ MaybeModedTInfo.setInt((isTransparent << 1) | 1);<br>
return isTransparent;<br>
}<br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>