hokein added a comment. > Would it be possible to compile some big file in LLVM (probably doesn't > matter much which, Sema something?) and observe if there's a significant > change in overall ASTContext size?
~3% saving (measuring the `ASTContext::.getASTAllocatedMemory`) | | Before | After | | SemaDecl.cpp | 255.5 MB | 247.5MB | | SemaExpr.cpp | 293.5 MB | 283.5MB | ================ Comment at: clang/include/clang/AST/TemplateBase.h:43 +// the dependency. +template <> struct PointerLikeTypeTraits<clang::Expr *> { + static inline void *getAsVoidPointer(clang::Expr *P) { return P; } ---------------- sammccall wrote: > At first glance this is unsafe: you could have two different definitions of > the same specialization in different files. > > In fact it's OK, the default one can now never be instantiated, because > Expr.h includes this file and so anyone that can see the definition can see > this specialization. > > But this is subtle/fragile: at least it needs to be spelled out explicitly in > the comment. > I'd also suggest adding a static assert below the definition of Expr that it > is compatible with this specialization (because it is sufficiently aligned). > > (I can't think of a better alternative - use of PointerUnion is a win, partly > *because* it validates the alignment) yes, exactly. do you have a better idea on how the static_assert should look like? The way I can think of is to add a new flag in this specialization, and use `static_assert(PointerLikeTypeTraits<clang::Expr *>::flag, "...")`. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D87080/new/ https://reviews.llvm.org/D87080 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits