Author: Haojian Wu
Date: 2025-06-06T16:25:36+02:00
New Revision: b6364ab9558277e877b2da2dfdff36e805dafa8d

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

LOG: [clang] Reduce TemplateDeclInstantiator size. (#142983)

This gives us another ~1.85% improvement (1617->1647 for the
`instantiation-depth-default.cpp`) on clang's template instantiation
depths,

No performance regressions have been observed:
https://llvm-compile-time-tracker.com/compare.php?from=702e228249906d43687952d9a2f3d2f90d8024c6&to=61be4bfea92d52cfc3e48a3cabb1bc80cbebb7fa&stat=instructions:u

Added: 
    

Modified: 
    clang/include/clang/Sema/Template.h
    clang/lib/Sema/SemaTemplateInstantiateDecl.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Sema/Template.h 
b/clang/include/clang/Sema/Template.h
index af0c1e8506cf3..fe907078af275 100644
--- a/clang/include/clang/Sema/Template.h
+++ b/clang/include/clang/Sema/Template.h
@@ -587,16 +587,17 @@ enum class TemplateSubstitutionKind : char {
     /// specializations that will need to be instantiated after the
     /// enclosing class's instantiation is complete.
     SmallVector<std::pair<ClassTemplateDecl *,
-                                ClassTemplatePartialSpecializationDecl *>, 4>
-      OutOfLinePartialSpecs;
+                          ClassTemplatePartialSpecializationDecl *>,
+                1>
+        OutOfLinePartialSpecs;
 
     /// A list of out-of-line variable template partial
     /// specializations that will need to be instantiated after the
     /// enclosing variable's instantiation is complete.
     /// FIXME: Verify that this is needed.
     SmallVector<
-        std::pair<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>, 
4>
-    OutOfLineVarPartialSpecs;
+        std::pair<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>, 
1>
+        OutOfLineVarPartialSpecs;
 
   public:
     TemplateDeclInstantiator(Sema &SemaRef, DeclContext *Owner,

diff  --git a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp 
b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
index b8e830cc30be1..57271415f838c 100644
--- a/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -2394,7 +2394,7 @@ Decl 
*TemplateDeclInstantiator::VisitVarTemplateDecl(VarTemplateDecl *D) {
     // Queue up any out-of-line partial specializations of this member
     // variable template; the client will force their instantiation once
     // the enclosing class has been instantiated.
-    SmallVector<VarTemplatePartialSpecializationDecl *, 4> PartialSpecs;
+    SmallVector<VarTemplatePartialSpecializationDecl *, 1> PartialSpecs;
     D->getPartialSpecializations(PartialSpecs);
     for (unsigned I = 0, N = PartialSpecs.size(); I != N; ++I)
       if (PartialSpecs[I]->getFirstDecl()->isOutOfLine())


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to