Fixup nested try blocks.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@90576 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGException.cpp b/lib/CodeGen/CGException.cpp
index 3de3004..62064ec 100644
--- a/lib/CodeGen/CGException.cpp
+++ b/lib/CodeGen/CGException.cpp
@@ -481,8 +481,18 @@
EmitBranch(FinallyEnd);
EmitBlock(FinallyRethrow);
- Builder.CreateCall(getUnwindResumeOrRethrowFn(*this),
- Builder.CreateLoad(RethrowPtr));
+ // FIXME: Eventually we can chain the handlers together and just do a call
+ // here.
+ if (getInvokeDest()) {
+ llvm::BasicBlock *Cont = createBasicBlock("invoke.cont");
+ Builder.CreateInvoke(getUnwindResumeOrRethrowFn(*this), Cont,
+ getInvokeDest(),
+ Builder.CreateLoad(RethrowPtr));
+ EmitBlock(Cont);
+ } else
+ Builder.CreateCall(getUnwindResumeOrRethrowFn(*this),
+ Builder.CreateLoad(RethrowPtr));
+
Builder.CreateUnreachable();
EmitBlock(FinallyEnd);