From bfcc823a5c53dabab8cfc842bfea70e2b69cdee0 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Sat, 15 May 2010 17:55:51 +0000 Subject: When initializing thread-safe statics, put the call to __cxa_guard_abort along the exceptional edge into (in effect) a nested "try" that rethrows after aborting. Fixes PR7144 and the remaining Boost.ProgramOptions failures. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103880 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGException.cpp | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'lib/CodeGen/CGException.cpp') diff --git a/lib/CodeGen/CGException.cpp b/lib/CodeGen/CGException.cpp index c1d05bf233..76a57d6f55 100644 --- a/lib/CodeGen/CGException.cpp +++ b/lib/CodeGen/CGException.cpp @@ -239,19 +239,23 @@ static void CopyObject(CodeGenFunction &CGF, QualType ObjectType, } } +void CodeGenFunction::EmitRethrow() { + if (getInvokeDest()) { + llvm::BasicBlock *Cont = createBasicBlock("invoke.cont"); + Builder.CreateInvoke(getReThrowFn(*this), Cont, getInvokeDest()) + ->setDoesNotReturn(); + EmitBlock(Cont); + } else + Builder.CreateCall(getReThrowFn(*this))->setDoesNotReturn(); + Builder.CreateUnreachable(); + + // Clear the insertion point to indicate we are in unreachable code. + Builder.ClearInsertionPoint(); +} + void CodeGenFunction::EmitCXXThrowExpr(const CXXThrowExpr *E) { if (!E->getSubExpr()) { - if (getInvokeDest()) { - llvm::BasicBlock *Cont = createBasicBlock("invoke.cont"); - Builder.CreateInvoke(getReThrowFn(*this), Cont, getInvokeDest()) - ->setDoesNotReturn(); - EmitBlock(Cont); - } else - Builder.CreateCall(getReThrowFn(*this))->setDoesNotReturn(); - Builder.CreateUnreachable(); - - // Clear the insertion point to indicate we are in unreachable code. - Builder.ClearInsertionPoint(); + EmitRethrow(); return; } @@ -562,6 +566,7 @@ void CodeGenFunction::ExitCXXTryStmt(const CXXTryStmt &S, // FIXME: we need to do this sooner so that the EH region for the // cleanup doesn't start until after the ctor completes, use a decl // init? + // FIXME: Alternatively, can we just elide this copy entirely? CopyObject(*this, CatchParam->getType().getNonReferenceType(), WasPointer, WasPointerReference, ExcObject, GetAddrOfLocalVar(CatchParam)); -- cgit v1.2.3-70-g09d2