diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-12-10 01:10:13 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-12-10 01:10:13 +0000 |
commit | 036e2bd07acf2dab2a46382627c48f84943dac4b (patch) | |
tree | 0c6690960d4ea3587f50712248257c049e6675b4 /clang/lib/AST/ExprConstant.cpp | |
parent | 6c8d29f7d1576a32d07cd6742087a8648a07f594 (diff) | |
download | bcm5719-llvm-036e2bd07acf2dab2a46382627c48f84943dac4b.tar.gz bcm5719-llvm-036e2bd07acf2dab2a46382627c48f84943dac4b.zip |
Add a fast path to the constant evaluator for integer literals. This speeds up
compilation of some translation units of SPEC's 445.gobmk by ~4%, and does not
seem to cause a measurable slowdown in other cases.
llvm-svn: 146306
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 5162c625d16..1ef3605f206 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -4602,6 +4602,14 @@ static bool EvaluateAsRValue(EvalInfo &Info, const Expr *E, APValue &Result) { /// in Result. If this expression is a glvalue, an lvalue-to-rvalue conversion /// will be applied to the result. bool Expr::EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx) const { + // Fast-path evaluations of integer literals, since we sometimes see files + // containing vast quantities of these. + if (const IntegerLiteral *L = dyn_cast<IntegerLiteral>(this)) { + Result.Val = APValue(APSInt(L->getValue(), + L->getType()->isUnsignedIntegerType())); + return true; + } + // FIXME: Evaluating initializers for large arrays can cause performance // problems, and we don't use such values yet. Once we have a more efficient // array representation, this should be reinstated, and used by CodeGen. |