diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-01-14 04:30:29 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2012-01-14 04:30:29 +0000 |
commit | dafff947599e3e397d39bc3ee3c36e51f34c1375 (patch) | |
tree | 592df6135488708bc3fd9f3e281bf7e19804671b /clang/lib/AST/ExprConstant.cpp | |
parent | 23ef0d6c40f29b6c685f1737ac092e61c33aa219 (diff) | |
download | bcm5719-llvm-dafff947599e3e397d39bc3ee3c36e51f34c1375.tar.gz bcm5719-llvm-dafff947599e3e397d39bc3ee3c36e51f34c1375.zip |
constexpr irgen: Add irgen support for APValue::Struct, APValue::Union,
APValue::Array and APValue::MemberPointer. All APValue values can now be emitted
as constants.
Add new CGCXXABI entry point for emitting an APValue MemberPointer. The other
entrypoints dealing with constant member pointers are no longer necessary and
will be removed in a later change.
Switch codegen from using EvaluateAsRValue/EvaluateAsLValue to
VarDecl::evaluateValue. This performs caching and deals with the nasty cases in
C++11 where a non-const object's initializer can refer indirectly to
previously-initialized fields within the same object.
Building the intermediate APValue object incurs a measurable performance hit on
pathological testcases with huge initializer lists, so we continue to build IR
directly from the Expr nodes for array and record types outside of C++11.
llvm-svn: 148178
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 912b111d617..ec5111579a2 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -5413,15 +5413,12 @@ bool Expr::EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx) const { 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. - // The same problem affects large records. + // FIXME: Evaluating values of large array and record types can cause + // performance problems. Only do so in C++11 for now. if (isRValue() && (getType()->isArrayType() || getType()->isRecordType()) && !Ctx.getLangOptions().CPlusPlus0x) return false; - // FIXME: If this is the initializer for an lvalue, pass that in. EvalInfo Info(Ctx, Result); return ::EvaluateAsRValue(Info, this, Result.Val); } @@ -5461,6 +5458,12 @@ bool Expr::EvaluateAsLValue(EvalResult &Result, const ASTContext &Ctx) const { bool Expr::EvaluateAsInitializer(APValue &Value, const ASTContext &Ctx, const VarDecl *VD, llvm::SmallVectorImpl<PartialDiagnosticAt> &Notes) const { + // FIXME: Evaluating initializers for large array and record types can cause + // performance problems. Only do so in C++11 for now. + if (isRValue() && (getType()->isArrayType() || getType()->isRecordType()) && + !Ctx.getLangOptions().CPlusPlus0x) + return false; + Expr::EvalStatus EStatus; EStatus.Diag = &Notes; |