[llvm-branch-commits] [cfe-branch] r102295 - in /cfe/branches/Apple/williamson: lib/CodeGen/CGObjCMac.cpp test/CodeGenObjC/exceptions.m
Daniel Dunbar
daniel at zuster.org
Sat Apr 24 19:32:44 PDT 2010
Author: ddunbar
Date: Sat Apr 24 21:32:44 2010
New Revision: 102295
URL: http://llvm.org/viewvc/llvm-project?rev=102295&view=rev
Log:
NeXT/EH: When generating the rethrow code for a finally block, make sure to chain outwards when inside a nested exception scope. - A real test for this is going into LLVM test-suite.
Added:
cfe/branches/Apple/williamson/test/CodeGenObjC/exceptions.m
Modified:
cfe/branches/Apple/williamson/lib/CodeGen/CGObjCMac.cpp
Modified: cfe/branches/Apple/williamson/lib/CodeGen/CGObjCMac.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/williamson/lib/CodeGen/CGObjCMac.cpp?rev=102295&r1=102294&r2=102295&view=diff
==============================================================================
--- cfe/branches/Apple/williamson/lib/CodeGen/CGObjCMac.cpp (original)
+++ cfe/branches/Apple/williamson/lib/CodeGen/CGObjCMac.cpp Sat Apr 24 21:32:44 2010
@@ -5768,9 +5768,19 @@
// Branch around the rethrow code.
CGF.EmitBranch(FinallyEnd);
+ // Generate the rethrow code, taking care to use an invoke if we are in a
+ // nested exception scope.
CGF.EmitBlock(FinallyRethrow);
- CGF.Builder.CreateCall(ObjCTypes.getUnwindResumeOrRethrowFn(),
- CGF.Builder.CreateLoad(RethrowPtr));
+ if (PrevLandingPad) {
+ llvm::BasicBlock *Cont = CGF.createBasicBlock("invoke.cont");
+ CGF.Builder.CreateInvoke(ObjCTypes.getUnwindResumeOrRethrowFn(),
+ Cont, PrevLandingPad,
+ CGF.Builder.CreateLoad(RethrowPtr));
+ CGF.EmitBlock(Cont);
+ } else {
+ CGF.Builder.CreateCall(ObjCTypes.getUnwindResumeOrRethrowFn(),
+ CGF.Builder.CreateLoad(RethrowPtr));
+ }
CGF.Builder.CreateUnreachable();
CGF.EmitBlock(FinallyEnd);
Added: cfe/branches/Apple/williamson/test/CodeGenObjC/exceptions.m
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/williamson/test/CodeGenObjC/exceptions.m?rev=102295&view=auto
==============================================================================
--- cfe/branches/Apple/williamson/test/CodeGenObjC/exceptions.m (added)
+++ cfe/branches/Apple/williamson/test/CodeGenObjC/exceptions.m Sat Apr 24 21:32:44 2010
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -o %t %s
+//
+// <rdar://problem/7471679> [irgen] [eh] Exception code built with clang (x86_64) crashes
+
+// Just check that we don't emit any dead blocks.
+//
+// RUN: grep 'No predecessors' %t | count 0
+
+ at interface NSArray @end
+void f0() {
+ @try {
+ @try {
+ @throw @"a";
+ } @catch(NSArray *e) {
+ }
+ } @catch (id e) {
+ }
+}
More information about the llvm-branch-commits
mailing list