diff options
| author | John McCall <rjmccall@apple.com> | 2010-10-26 08:39:16 +0000 | 
|---|---|---|
| committer | John McCall <rjmccall@apple.com> | 2010-10-26 08:39:16 +0000 | 
| commit | 925b16629daa32073b33aba986a2dbb9a6920ec5 (patch) | |
| tree | 4ac82485c80a603368c4c64b690b3e158c717b2f /clang/lib | |
| parent | c3007a21450f438be3094cd1fd41168bb2d8a587 (diff) | |
| download | bcm5719-llvm-925b16629daa32073b33aba986a2dbb9a6920ec5.tar.gz bcm5719-llvm-925b16629daa32073b33aba986a2dbb9a6920ec5.zip | |
Optimize field space usage in CompoundStmt, LabelStmt, Expr, and CastExpr.
There's probably still significant padding waste on x86-64 UNIXen, but
the difference in 32-bit compiles should be significant.
There are a lot of Expr nodes left that could lose a word this way.
llvm-svn: 117359
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/AST/Expr.cpp | 32 | ||||
| -rw-r--r-- | clang/lib/AST/Stmt.cpp | 10 | 
2 files changed, 22 insertions, 20 deletions
| diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index 92e7119445b..011887b9a71 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -124,8 +124,8 @@ std::size_t ExplicitTemplateArgumentList::sizeFor(  }  void DeclRefExpr::computeDependence() { -  TypeDependent = false; -  ValueDependent = false; +  ExprBits.TypeDependent = false; +  ExprBits.ValueDependent = false;    NamedDecl *D = getDecl(); @@ -140,27 +140,27 @@ void DeclRefExpr::computeDependence() {    //  (TD)  - an identifier that was declared with dependent type    //  (VD)  - a name declared with a dependent type,    if (getType()->isDependentType()) { -    TypeDependent = true; -    ValueDependent = true; +    ExprBits.TypeDependent = true; +    ExprBits.ValueDependent = true;    }    //  (TD)  - a conversion-function-id that specifies a dependent type    else if (D->getDeclName().getNameKind()                                  == DeclarationName::CXXConversionFunctionName &&             D->getDeclName().getCXXNameType()->isDependentType()) { -    TypeDependent = true; -    ValueDependent = true; +    ExprBits.TypeDependent = true; +    ExprBits.ValueDependent = true;    }    //  (TD)  - a template-id that is dependent,    else if (hasExplicitTemplateArgs() &&              TemplateSpecializationType::anyDependentTemplateArguments(                                                         getTemplateArgs(),                                                          getNumTemplateArgs())) { -    TypeDependent = true; -    ValueDependent = true; +    ExprBits.TypeDependent = true; +    ExprBits.ValueDependent = true;    }    //  (VD)  - the name of a non-type template parameter,    else if (isa<NonTypeTemplateParmDecl>(D)) -    ValueDependent = true; +    ExprBits.ValueDependent = true;    //  (VD) - a constant with integral or enumeration type and is    //         initialized with an expression that is value-dependent.    else if (VarDecl *Var = dyn_cast<VarDecl>(D)) { @@ -168,20 +168,20 @@ void DeclRefExpr::computeDependence() {          Var->getType().getCVRQualifiers() == Qualifiers::Const) {        if (const Expr *Init = Var->getAnyInitializer())          if (Init->isValueDependent()) -          ValueDependent = true; +          ExprBits.ValueDependent = true;      }       // (VD) - FIXME: Missing from the standard:       //      -  a member function or a static data member of the current       //         instantiation      else if (Var->isStaticDataMember() &&                Var->getDeclContext()->isDependentContext()) -      ValueDependent = true; +      ExprBits.ValueDependent = true;    }     // (VD) - FIXME: Missing from the standard:     //      -  a member function or a static data member of the current     //         instantiation    else if (isa<CXXMethodDecl>(D) && D->getDeclContext()->isDependentContext()) -    ValueDependent = true; +    ExprBits.ValueDependent = true;    //  (TD)  - a nested-name-specifier or a qualified-id that names a    //          member of an unknown specialization.    //        (handled by DependentScopeDeclRefExpr) @@ -999,9 +999,9 @@ InitListExpr::InitListExpr(ASTContext &C, SourceLocation lbraceloc,  {          for (unsigned I = 0; I != numInits; ++I) {      if (initExprs[I]->isTypeDependent()) -      TypeDependent = true; +      ExprBits.TypeDependent = true;      if (initExprs[I]->isValueDependent()) -      ValueDependent = true; +      ExprBits.ValueDependent = true;    }    InitExprs.insert(C, InitExprs.end(), initExprs, initExprs+numInits); @@ -2224,7 +2224,7 @@ DesignatedInitExpr::DesignatedInitExpr(ASTContext &C, QualType Ty,      if (this->Designators[I].isArrayDesignator()) {        // Compute type- and value-dependence.        Expr *Index = IndexExprs[IndexIdx]; -      ValueDependent = ValueDependent || +      ExprBits.ValueDependent = ExprBits.ValueDependent ||          Index->isTypeDependent() || Index->isValueDependent();        // Copy the index expressions into permanent storage. @@ -2233,7 +2233,7 @@ DesignatedInitExpr::DesignatedInitExpr(ASTContext &C, QualType Ty,        // Compute type- and value-dependence.        Expr *Start = IndexExprs[IndexIdx];        Expr *End = IndexExprs[IndexIdx + 1]; -      ValueDependent = ValueDependent || +      ExprBits.ValueDependent = ExprBits.ValueDependent ||          Start->isTypeDependent() || Start->isValueDependent() ||          End->isTypeDependent() || End->isValueDependent(); diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp index cc4b6c9ddb9..4f46b350408 100644 --- a/clang/lib/AST/Stmt.cpp +++ b/clang/lib/AST/Stmt.cpp @@ -46,7 +46,7 @@ static StmtClassNameTable &getStmtInfoTableEntry(Stmt::StmtClass E) {  }  const char *Stmt::getStmtClassName() const { -  return getStmtInfoTableEntry((StmtClass)sClass).Name; +  return getStmtInfoTableEntry((StmtClass) StmtBits.sClass).Name;  }  void Stmt::PrintStats() { @@ -87,7 +87,7 @@ bool Stmt::CollectingStats(bool Enable) {  void CompoundStmt::setStmts(ASTContext &C, Stmt **Stmts, unsigned NumStmts) {    if (this->Body)      C.Deallocate(Body); -  this->NumStmts = NumStmts; +  this->CompoundStmtBits.NumStmts = NumStmts;    Body = new (C) Stmt*[NumStmts];    memcpy(Body, Stmts, sizeof(Stmt *) * NumStmts); @@ -106,7 +106,7 @@ SourceRange ReturnStmt::getSourceRange() const {  }  bool Stmt::hasImplicitControlFlow() const { -  switch (sClass) { +  switch (StmtBits.sClass) {      default:        return false; @@ -604,7 +604,9 @@ Stmt::child_iterator NullStmt::child_end() { return child_iterator(); }  // CompoundStmt  Stmt::child_iterator CompoundStmt::child_begin() { return &Body[0]; } -Stmt::child_iterator CompoundStmt::child_end() { return &Body[0]+NumStmts; } +Stmt::child_iterator CompoundStmt::child_end() { +  return &Body[0]+CompoundStmtBits.NumStmts; +}  // CaseStmt  Stmt::child_iterator CaseStmt::child_begin() { return &SubExprs[0]; } | 

