[cfe-commits] r62612 - /cfe/trunk/lib/Sema/SemaExpr.cpp
Steve Naroff
snaroff at apple.com
Tue Jan 20 13:06:31 PST 2009
Author: snaroff
Date: Tue Jan 20 15:06:31 2009
New Revision: 62612
URL: http://llvm.org/viewvc/llvm-project?rev=62612&view=rev
Log:
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()).
Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=62612&r1=62611&r2=62612&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Jan 20 15:06:31 2009
@@ -3529,11 +3529,14 @@
}
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 @@
// 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 @@
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".
More information about the cfe-commits
mailing list