[cfe-commits] r72582 - in /cfe/trunk/lib/Sema: SemaTemplateInstantiate.cpp SemaTemplateInstantiateDecl.cpp SemaTemplateInstantiateExpr.cpp SemaTemplateInstantiateStmt.cpp

Douglas Gregor dgregor at apple.com
Fri May 29 11:27:38 PDT 2009


Author: dgregor
Date: Fri May 29 13:27:38 2009
New Revision: 72582

URL: http://llvm.org/viewvc/llvm-project?rev=72582&view=rev
Log:
Reduce the amount of stack space we use in SmallVectors during
template instantiation. This helps reduce our stack footprint when
performing deep template instantiations.

Modified:
    cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
    cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
    cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp
    cfe/trunk/lib/Sema/SemaTemplateInstantiateStmt.cpp

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp?rev=72582&r1=72581&r2=72582&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiate.cpp Fri May 29 13:27:38 2009
@@ -378,7 +378,7 @@
   if (ResultType.isNull())
     return ResultType;
 
-  llvm::SmallVector<QualType, 16> ParamTypes;
+  llvm::SmallVector<QualType, 4> ParamTypes;
   for (FunctionProtoType::arg_type_iterator Param = T->arg_type_begin(),
                                          ParamEnd = T->arg_type_end(); 
        Param != ParamEnd; ++Param) {
@@ -497,7 +497,7 @@
 InstantiateTemplateSpecializationType(
                                   const TemplateSpecializationType *T,
                                   unsigned Quals) const {
-  llvm::SmallVector<TemplateArgument, 16> InstantiatedTemplateArgs;
+  llvm::SmallVector<TemplateArgument, 4> InstantiatedTemplateArgs;
   InstantiatedTemplateArgs.reserve(T->getNumArgs());
   for (TemplateSpecializationType::iterator Arg = T->begin(), ArgEnd = T->end();
        Arg != ArgEnd; ++Arg) {
@@ -669,7 +669,7 @@
                                 CXXRecordDecl *Pattern,
                                 const TemplateArgumentList &TemplateArgs) {
   bool Invalid = false;
-  llvm::SmallVector<CXXBaseSpecifier*, 8> InstantiatedBases;
+  llvm::SmallVector<CXXBaseSpecifier*, 4> InstantiatedBases;
   for (ClassTemplateSpecializationDecl::base_class_iterator 
          Base = Pattern->bases_begin(), BaseEnd = Pattern->bases_end();
        Base != BaseEnd; ++Base) {
@@ -767,7 +767,7 @@
   if (InstantiateBaseSpecifiers(Instantiation, Pattern, TemplateArgs))
     Invalid = true;
 
-  llvm::SmallVector<DeclPtrTy, 32> Fields;
+  llvm::SmallVector<DeclPtrTy, 4> Fields;
   for (RecordDecl::decl_iterator Member = Pattern->decls_begin(Context),
          MemberEnd = Pattern->decls_end(Context); 
        Member != MemberEnd; ++Member) {

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=72582&r1=72581&r2=72582&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Fri May 29 13:27:38 2009
@@ -214,7 +214,7 @@
   Owner->addDecl(SemaRef.Context, Enum);
   Enum->startDefinition();
 
-  llvm::SmallVector<Sema::DeclPtrTy, 16> Enumerators;
+  llvm::SmallVector<Sema::DeclPtrTy, 4> Enumerators;
 
   EnumConstantDecl *LastEnumConst = 0;
   for (EnumDecl::enumerator_iterator EC = D->enumerator_begin(SemaRef.Context),
@@ -288,7 +288,7 @@
 
   Sema::LocalInstantiationScope Scope(SemaRef);
 
-  llvm::SmallVector<ParmVarDecl *, 16> Params;
+  llvm::SmallVector<ParmVarDecl *, 4> Params;
   QualType T = InstantiateFunctionType(D, Params);
   if (T.isNull())
     return 0;
@@ -331,7 +331,7 @@
 Decl *TemplateDeclInstantiator::VisitCXXConstructorDecl(CXXConstructorDecl *D) {
   Sema::LocalInstantiationScope Scope(SemaRef);
 
-  llvm::SmallVector<ParmVarDecl *, 16> Params;
+  llvm::SmallVector<ParmVarDecl *, 4> Params;
   QualType T = InstantiateFunctionType(D, Params);
   if (T.isNull())
     return 0;
@@ -378,7 +378,7 @@
 Decl *TemplateDeclInstantiator::VisitCXXDestructorDecl(CXXDestructorDecl *D) {
   Sema::LocalInstantiationScope Scope(SemaRef);
 
-  llvm::SmallVector<ParmVarDecl *, 16> Params;
+  llvm::SmallVector<ParmVarDecl *, 4> Params;
   QualType T = InstantiateFunctionType(D, Params);
   if (T.isNull())
     return 0;
@@ -409,7 +409,7 @@
 Decl *TemplateDeclInstantiator::VisitCXXConversionDecl(CXXConversionDecl *D) {
   Sema::LocalInstantiationScope Scope(SemaRef);
 
-  llvm::SmallVector<ParmVarDecl *, 16> Params;
+  llvm::SmallVector<ParmVarDecl *, 4> Params;
   QualType T = InstantiateFunctionType(D, Params);
   if (T.isNull())
     return 0;
@@ -505,7 +505,7 @@
 
   // Instantiate the function parameters
   TemplateDeclInstantiator ParamInstantiator(SemaRef, 0, TemplateArgs);
-  llvm::SmallVector<QualType, 16> ParamTys;
+  llvm::SmallVector<QualType, 4> ParamTys;
   for (FunctionDecl::param_iterator P = D->param_begin(), 
                                  PEnd = D->param_end();
        P != PEnd; ++P) {

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp?rev=72582&r1=72581&r2=72582&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateExpr.cpp Fri May 29 13:27:38 2009
@@ -575,7 +575,7 @@
 
 Sema::OwningExprResult 
 TemplateExprInstantiator::VisitInitListExpr(InitListExpr *E) {
-  ExprVector Inits(SemaRef);
+  ASTOwningVector<&ActionBase::DeleteExpr, 4> Inits(SemaRef);
   for (unsigned I = 0, N = E->getNumInits(); I != N; ++I) {
     OwningExprResult Init = Visit(E->getInit(I));
     if (Init.isInvalid())
@@ -597,7 +597,7 @@
     return SemaRef.ExprError();
 
   // Instantiate the designators.
-  ExprVector ArrayExprs(SemaRef); // Expresses used in array designators
+  ASTOwningVector<&ActionBase::DeleteExpr, 4> ArrayExprs(SemaRef);
   for (DesignatedInitExpr::designators_iterator D = E->designators_begin(),
                                              DEnd = E->designators_end();
        D != DEnd; ++D) {

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateStmt.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateStmt.cpp?rev=72582&r1=72581&r2=72582&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateStmt.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateStmt.cpp Fri May 29 13:27:38 2009
@@ -60,7 +60,7 @@
 //  Common/C statements
 //===----------------------------------------------------------------------===/
 Sema::OwningStmtResult TemplateStmtInstantiator::VisitDeclStmt(DeclStmt *S) {
-  llvm::SmallVector<Decl *, 8> Decls;
+  llvm::SmallVector<Decl *, 4> Decls;
   for (DeclStmt::decl_iterator D = S->decl_begin(), DEnd = S->decl_end();
        D != DEnd; ++D) {
     Decl *Instantiated = SemaRef.InstantiateDecl(*D, SemaRef.CurContext, 





More information about the cfe-commits mailing list