diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-12-30 21:15:51 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2011-12-30 21:15:51 +0000 |
commit | 51201882382fb40c9456a06c7f93d6ddd4a57712 (patch) | |
tree | 2b485b2651f5385cda9709b77582bf4320e3569f /lib/CodeGen/CGDecl.cpp | |
parent | bf3cc73db94f2fbeb57929887bd05d5a0e077f0c (diff) |
Unrevert r147271, reverted in r147361.
Also temporarily remove the assumption from IR gen that we can emit IR for every
constant we can fold, since it isn't currently true in C++11, to fix PR11676.
Original comment from r147271:
constexpr: perform zero-initialization prior to / instead of performing a
constructor call when appropriate. Thanks to Eli for spotting this.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147384 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGDecl.cpp')
-rw-r--r-- | lib/CodeGen/CGDecl.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index e8f00e7dde..43077cefa0 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -970,7 +970,13 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) { llvm::Value *Loc = capturedByInit ? emission.Address : emission.getObjectAddress(*this); - if (!emission.IsConstantAggregate) { + llvm::Constant *constant = 0; + if (emission.IsConstantAggregate) { + assert(!capturedByInit && "constant init contains a capturing block?"); + constant = CGM.EmitConstantExpr(D.getInit(), type, this); + } + + if (!constant) { LValue lv = MakeAddrLValue(Loc, type, alignment); lv.setNonGC(true); return EmitExprAsInit(Init, &D, lv, capturedByInit); @@ -978,13 +984,8 @@ void CodeGenFunction::EmitAutoVarInit(const AutoVarEmission &emission) { // If this is a simple aggregate initialization, we can optimize it // in various ways. - assert(!capturedByInit && "constant init contains a capturing block?"); - bool isVolatile = type.isVolatileQualified(); - llvm::Constant *constant = CGM.EmitConstantExpr(D.getInit(), type, this); - assert(constant != 0 && "Wasn't a simple constant init?"); - llvm::Value *SizeVal = llvm::ConstantInt::get(IntPtrTy, getContext().getTypeSizeInChars(type).getQuantity()); |