diff options
| author | Bruno Ricci <riccibrun@gmail.com> | 2018-10-27 21:12:20 +0000 |
|---|---|---|
| committer | Bruno Ricci <riccibrun@gmail.com> | 2018-10-27 21:12:20 +0000 |
| commit | b1cc94b2e559f12986efaf24d681d4098ee0b3f1 (patch) | |
| tree | 03a2e1aec759e38a8065de57d8edfa702e0096b6 /clang/lib/Analysis/BodyFarm.cpp | |
| parent | a5baf86744296f2e8769557e2c41d64d07791766 (diff) | |
| download | bcm5719-llvm-b1cc94b2e559f12986efaf24d681d4098ee0b3f1.tar.gz bcm5719-llvm-b1cc94b2e559f12986efaf24d681d4098ee0b3f1.zip | |
[AST] Only store the needed data in IfStmt
Only store the needed data in IfStmt. This cuts the size of IfStmt
by up to 3 pointers + 1 SourceLocation. The order of the children
is intentionally kept the same even though it would be more
convenient to put the optional trailing objects last. Additionally
use the newly available space in the bit-fields of Stmt to store
the location of the "if".
The result of this is that for the common case of an
if statement of the form:
if (some_cond)
some_statement
the size of IfStmt is brought down to 8 bytes + 2 pointers,
instead of 8 bytes + 5 pointers + 2 SourceLocation.
Differential Revision: https://reviews.llvm.org/D53607
Reviewed By: rjmccall
llvm-svn: 345464
Diffstat (limited to 'clang/lib/Analysis/BodyFarm.cpp')
| -rw-r--r-- | clang/lib/Analysis/BodyFarm.cpp | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/clang/lib/Analysis/BodyFarm.cpp b/clang/lib/Analysis/BodyFarm.cpp index ac8fcdc912a..57e7d8dfdb0 100644 --- a/clang/lib/Analysis/BodyFarm.cpp +++ b/clang/lib/Analysis/BodyFarm.cpp @@ -464,13 +464,13 @@ static Stmt *create_call_once(ASTContext &C, const FunctionDecl *D) { Deref, M.makeIntegralCast(M.makeIntegerLiteral(1, C.IntTy), DerefType), DerefType); - IfStmt *Out = new (C) - IfStmt(C, SourceLocation(), - /* IsConstexpr=*/ false, - /* init=*/ nullptr, - /* var=*/ nullptr, - /* cond=*/ FlagCheck, - /* then=*/ M.makeCompound({CallbackCall, FlagAssignment})); + auto *Out = + IfStmt::Create(C, SourceLocation(), + /* IsConstexpr=*/false, + /* init=*/nullptr, + /* var=*/nullptr, + /* cond=*/FlagCheck, + /* then=*/M.makeCompound({CallbackCall, FlagAssignment})); return Out; } @@ -549,12 +549,12 @@ static Stmt *create_dispatch_once(ASTContext &C, const FunctionDecl *D) { Expr *GuardCondition = M.makeComparison(LValToRval, DoneValue, BO_NE); // (5) Create the 'if' statement. - IfStmt *If = new (C) IfStmt(C, SourceLocation(), - /* IsConstexpr=*/ false, - /* init=*/ nullptr, - /* var=*/ nullptr, - /* cond=*/ GuardCondition, - /* then=*/ CS); + auto *If = IfStmt::Create(C, SourceLocation(), + /* IsConstexpr=*/false, + /* init=*/nullptr, + /* var=*/nullptr, + /* cond=*/GuardCondition, + /* then=*/CS); return If; } @@ -657,8 +657,11 @@ static Stmt *create_OSAtomicCompareAndSwap(ASTContext &C, const FunctionDecl *D) Stmt *Else = M.makeReturn(RetVal); /// Construct the If. - Stmt *If = new (C) IfStmt(C, SourceLocation(), false, nullptr, nullptr, - Comparison, Body, SourceLocation(), Else); + auto *If = IfStmt::Create(C, SourceLocation(), + /* IsConstexpr=*/false, + /* init=*/nullptr, + /* var=*/nullptr, Comparison, Body, + SourceLocation(), Else); return If; } |

