diff options
| author | Steve Naroff <snaroff@apple.com> | 2009-01-20 21:06:31 +0000 |
|---|---|---|
| committer | Steve Naroff <snaroff@apple.com> | 2009-01-20 21:06:31 +0000 |
| commit | e5564628b467ecb7a717519e94f97a1d2ec5729a (patch) | |
| tree | 69a8319a35d549cb58b86cf0fee19a2f5ede4598 /clang/lib | |
| parent | 82c1fe1cfcfac87c240738c2abea135f4ef3e6f2 (diff) | |
| download | bcm5719-llvm-e5564628b467ecb7a717519e94f97a1d2ec5729a.tar.gz bcm5719-llvm-e5564628b467ecb7a717519e94f97a1d2ec5729a.zip | |
Convert more exprs to use ASTContext's Allocator.
When using a BumpPtrAllocator, this reduces malloc overhead from 2.2->1.9% (for Cocoa.h).
At this point, malloc() has dropped the fourth most expensive routine (behind Preprocessor::HandleIdentifier()).
llvm-svn: 62612
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/Sema/SemaExpr.cpp | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp index 33f21b91e1c..8a8fb731c77 100644 --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -3529,11 +3529,14 @@ Action::OwningExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc, } if (ResultTy.isNull()) return ExprError(); - if (CompTy.isNull()) - return Owned(new BinaryOperator(lhs, rhs, Opc, ResultTy, OpLoc)); - else - return Owned(new CompoundAssignOperator(lhs, rhs, Opc, ResultTy, - CompTy, OpLoc)); + if (CompTy.isNull()) { + void *Mem = Context.getAllocator().Allocate<BinaryOperator>(); + return Owned(new (Mem) BinaryOperator(lhs, rhs, Opc, ResultTy, OpLoc)); + } else { + void *Mem = Context.getAllocator().Allocate<CompoundAssignOperator>(); + return Owned(new (Mem) CompoundAssignOperator(lhs, rhs, Opc, ResultTy, + CompTy, OpLoc)); + } } // Binary Operators. 'Tok' is the token for the operator. @@ -3550,13 +3553,16 @@ Action::OwningExprResult Sema::ActOnBinOp(Scope *S, SourceLocation TokLoc, // FIXME: We'll need to perform some caching of the result of name // lookup for operator+. if (lhs->isTypeDependent() || rhs->isTypeDependent()) { - if (Opc > BinaryOperator::Assign && Opc <= BinaryOperator::OrAssign) - return Owned(new CompoundAssignOperator(lhs, rhs, Opc, + if (Opc > BinaryOperator::Assign && Opc <= BinaryOperator::OrAssign) { + void *Mem = Context.getAllocator().Allocate<CompoundAssignOperator>(); + return Owned(new (Mem) CompoundAssignOperator(lhs, rhs, Opc, Context.DependentTy, Context.DependentTy, TokLoc)); - else - return Owned(new BinaryOperator(lhs, rhs, Opc, Context.DependentTy, - TokLoc)); + } else { + void *Mem = Context.getAllocator().Allocate<BinaryOperator>(); + return Owned(new (Mem) BinaryOperator(lhs, rhs, Opc, Context.DependentTy, + TokLoc)); + } } if (getLangOptions().CPlusPlus && @@ -3832,7 +3838,8 @@ Action::OwningExprResult Sema::ActOnUnaryOp(Scope *S, SourceLocation OpLoc, if (resultType.isNull()) return ExprError(); input.release(); - return Owned(new UnaryOperator(Input, Opc, resultType, OpLoc)); + void *Mem = Context.getAllocator().Allocate<UnaryOperator>(); + return Owned(new (Mem) UnaryOperator(Input, Opc, resultType, OpLoc)); } /// ActOnAddrLabel - Parse the GNU address of label extension: "&&foo". |

