[PATCH] D118385: [NFC] Optimize FoldingSet usage where it matters

serge via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 27 09:31:05 PST 2022


serge-sans-paille added inline comments.


================
Comment at: clang/include/clang/AST/ASTContext.h:214
   mutable llvm::FoldingSet<ComplexType> ComplexTypes;
-  mutable llvm::FoldingSet<PointerType> PointerTypes;
+  mutable llvm::FoldingSet<PointerType> PointerTypes{9};
   mutable llvm::FoldingSet<AdjustedType> AdjustedTypes;
----------------
It's probably good to give that value a meaningful ( and `constexpr`) variable name as it's used at several point. 


================
Comment at: clang/lib/AST/ASTContext.cpp:976
                        Builtin::Context &builtins, TranslationUnitKind TUKind)
-    : ConstantArrayTypes(this_()), FunctionProtoTypes(this_()),
+    : ConstantArrayTypes(this_(), 8), FunctionProtoTypes(this_(), 12),
       TemplateSpecializationTypes(this_()),
----------------
same here, that's a lot of magic values :-)


================
Comment at: clang/lib/CodeGen/CodeGenTypes.h:79
   /// Hold memoized CGFunctionInfo results.
-  llvm::FoldingSet<CGFunctionInfo> FunctionInfos;
+  llvm::FoldingSet<CGFunctionInfo> FunctionInfos{9};
 
----------------
And here


================
Comment at: llvm/include/llvm/ADT/FoldingSet.h:328
   /// Add* - Add various data types to Bit data.
-  void AddPointer(const void *Ptr);
-  void AddInteger(signed I);
-  void AddInteger(unsigned I);
-  void AddInteger(long I);
-  void AddInteger(unsigned long I);
-  void AddInteger(long long I);
-  void AddInteger(unsigned long long I);
+  void AddPointer(const void *Ptr) {
+    // Note: this adds pointers to the hash using sizes and endianness that
----------------
Concerning that inlined part, I expect LTO to close the gap instead of moving everything to headers. Do we have a policy on that topic?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D118385/new/

https://reviews.llvm.org/D118385



More information about the llvm-commits mailing list