diff options
author | Chad Rosier <mcrosier@apple.com> | 2012-02-22 21:36:06 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@apple.com> | 2012-02-22 21:36:06 +0000 |
commit | 1a3c3d45374a74b753373747b9a326a3360c3ac4 (patch) | |
tree | c76e49bbfd42a1e56abe1ec45749413568cf8b3c /clang/lib/CodeGen/CGExprCXX.cpp | |
parent | f56ddeaa6f4df6cfec153311e13e3b372304214c (diff) | |
download | bcm5719-llvm-1a3c3d45374a74b753373747b9a326a3360c3ac4.tar.gz bcm5719-llvm-1a3c3d45374a74b753373747b9a326a3360c3ac4.zip |
Revert r151172: Unwind path cleanup for array new list initializers.
llvm-svn: 151203
Diffstat (limited to 'clang/lib/CodeGen/CGExprCXX.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGExprCXX.cpp | 39 |
1 files changed, 7 insertions, 32 deletions
diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp index 00fbe9bfb0a..af9c7662386 100644 --- a/clang/lib/CodeGen/CGExprCXX.cpp +++ b/clang/lib/CodeGen/CGExprCXX.cpp @@ -804,32 +804,12 @@ CodeGenFunction::EmitNewArrayInitializer(const CXXNewExpr *E, unsigned initializerElements = 0; const Expr *Init = E->getInitializer(); - llvm::AllocaInst *endOfInit = 0; - QualType::DestructionKind dtorKind = elementType.isDestructedType(); - EHScopeStack::stable_iterator cleanup; - llvm::Instruction *cleanupDominator = 0; // If the initializer is an initializer list, first do the explicit elements. if (const InitListExpr *ILE = dyn_cast<InitListExpr>(Init)) { initializerElements = ILE->getNumInits(); - - // Enter a partial-destruction cleanup if necessary. - if (needsEHCleanup(dtorKind)) { - // In principle we could tell the cleanup where we are more - // directly, but the control flow can get so varied here that it - // would actually be quite complex. Therefore we go through an - // alloca. - endOfInit = CreateTempAlloca(beginPtr->getType(), "array.endOfInit"); - cleanupDominator = Builder.CreateStore(beginPtr, endOfInit); - pushIrregularPartialArrayCleanup(beginPtr, endOfInit, elementType, - getDestroyer(dtorKind)); - cleanup = EHStack.stable_begin(); - } - + QualType elementType = E->getAllocatedType(); + // FIXME: exception-safety for the explicit initializers for (unsigned i = 0, e = ILE->getNumInits(); i != e; ++i) { - // Tell the cleanup that it needs to destroy up to this - // element. TODO: some of these stores can be trivially - // observed to be unnecessary. - if (endOfInit) Builder.CreateStore(explicitPtr, endOfInit); StoreAnyExprIntoOneUnit(*this, ILE->getInit(i), elementType, explicitPtr); explicitPtr =Builder.CreateConstGEP1_32(explicitPtr, 1, "array.exp.next"); } @@ -845,12 +825,7 @@ CodeGenFunction::EmitNewArrayInitializer(const CXXNewExpr *E, // anything left to initialize. if (llvm::ConstantInt *constNum = dyn_cast<llvm::ConstantInt>(numElements)) { // If all elements have already been initialized, skip the whole loop. - if (constNum->getZExtValue() <= initializerElements) { - // If there was a cleanup, deactivate it. - if (cleanupDominator) - DeactivateCleanupBlock(cleanup, cleanupDominator);; - return; - } + if (constNum->getZExtValue() <= initializerElements) return; } else { llvm::BasicBlock *nonEmptyBB = createBasicBlock("new.loop.nonempty"); llvm::Value *isEmpty = Builder.CreateICmpEQ(explicitPtr, endPtr, @@ -870,11 +845,11 @@ CodeGenFunction::EmitNewArrayInitializer(const CXXNewExpr *E, Builder.CreatePHI(explicitPtr->getType(), 2, "array.cur"); curPtr->addIncoming(explicitPtr, entryBB); - // Store the new cleanup position for irregular cleanups. - if (endOfInit) Builder.CreateStore(curPtr, endOfInit); - // Enter a partial-destruction cleanup if necessary. - if (!cleanupDominator && needsEHCleanup(dtorKind)) { + QualType::DestructionKind dtorKind = elementType.isDestructedType(); + EHScopeStack::stable_iterator cleanup; + llvm::Instruction *cleanupDominator = 0; + if (needsEHCleanup(dtorKind)) { pushRegularPartialArrayCleanup(beginPtr, curPtr, elementType, getDestroyer(dtorKind)); cleanup = EHStack.stable_begin(); |