[clang] 837ca47 - [NFCI] Change the data structure of MaybeODRUseExprSet

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Mon Jun 15 08:16:03 PDT 2020


Author: Erich Keane
Date: 2020-06-15T08:15:50-07:00
New Revision: 837ca4796065ccd0ac0d20860341ac06a9645009

URL: https://github.com/llvm/llvm-project/commit/837ca4796065ccd0ac0d20860341ac06a9645009
DIFF: https://github.com/llvm/llvm-project/commit/837ca4796065ccd0ac0d20860341ac06a9645009.diff

LOG: [NFCI] Change the data structure of MaybeODRUseExprSet

In 1eddce41, I fixed a non-deterministic result problem by switching a
SmallPtrSet to a SmallSetVector to ensure we iterated it
deterministically.  Unfortunately, this seems to show a surprisingly
significant compiletime impact.

This patch does 2 things in an attempt to fix this:

First, it makes the 'small size' optimization 4 instead of 2.  As these
are pointers, this only increases the size of Sema by 4
sizeof(pointer)s (2 for the set, 2 for the vector).

Second, instead of using SmallSetVector, which is a SmallVector +
SmallDenseSet, it uses a SetVector of SmallVector + SmallPtrSet.  The
hope is that the pointer-specific optimizations of the SmallPtrSet will
minimize the impact on compile-time.

Added: 
    

Modified: 
    clang/include/clang/Sema/Sema.h

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index a3f4313c0d65..754339c0181b 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -627,7 +627,8 @@ class Sema final {
   /// we won't know until all lvalue-to-rvalue and discarded value conversions
   /// have been applied to all subexpressions of the enclosing full expression.
   /// This is cleared at the end of each full expression.
-  using MaybeODRUseExprSet = llvm::SmallSetVector<Expr *, 2>;
+  using MaybeODRUseExprSet = llvm::SetVector<Expr *, SmallVector<Expr *, 4>,
+                                             llvm::SmallPtrSet<Expr *, 4>>;
   MaybeODRUseExprSet MaybeODRUseExprs;
 
   std::unique_ptr<sema::FunctionScopeInfo> CachedFunctionScope;


        


More information about the cfe-commits mailing list