r179630 - objc_autoreleasePoolPop() can throw if a -dealloc does.
John McCall
rjmccall at apple.com
Tue Apr 16 14:29:40 PDT 2013
Author: rjmccall
Date: Tue Apr 16 16:29:40 2013
New Revision: 179630
URL: http://llvm.org/viewvc/llvm-project?rev=179630&view=rev
Log:
objc_autoreleasePoolPop() can throw if a -dealloc does.
Model it as throwing so that the exception can be caught.
This is generally not expected to have significant code-size
impact because the contents of the @autoreleasepool block
are very likely to contain a call, very likely at the same
cleanup level as the @autoreleasepool itself.
rdar://13660038
Modified:
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/test/CodeGenObjC/autorelease.m
Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=179630&r1=179629&r2=179630&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Tue Apr 16 16:29:40 2013
@@ -21,6 +21,7 @@
#include "clang/AST/StmtObjC.h"
#include "clang/Basic/Diagnostic.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/CallSite.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/InlineAsm.h"
using namespace clang;
@@ -2256,7 +2257,8 @@ void CodeGenFunction::EmitObjCAutoreleas
fn = createARCRuntimeFunction(CGM, fnType, "objc_autoreleasePoolPop");
}
- EmitNounwindRuntimeCall(fn, value);
+ // objc_autoreleasePoolPop can throw.
+ EmitRuntimeCallOrInvoke(fn, value);
}
/// Produce the code to do an MRR version objc_autoreleasepool_push.
Modified: cfe/trunk/test/CodeGenObjC/autorelease.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/autorelease.m?rev=179630&r1=179629&r2=179630&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/autorelease.m (original)
+++ cfe/trunk/test/CodeGenObjC/autorelease.m Tue Apr 16 16:29:40 2013
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fobjc-runtime=macosx-10.7 -o - %s | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -emit-llvm -fobjc-runtime=macosx-10.7 -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -emit-llvm -fobjc-arc -fobjc-runtime=macosx-10.7 -fexceptions -fobjc-exceptions -o - %s | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -emit-llvm -fobjc-runtime=macosx-10.7 -fexceptions -fobjc-exceptions -o - %s | FileCheck %s
// rdar://8881826
// rdar://9412038
@@ -28,3 +28,26 @@
// CHECK: call i8* @objc_autoreleasePoolPush
// CHECK: [[T:%.*]] = load i8** [[A:%.*]]
// CHECK: call void @objc_autoreleasePoolPop
+
+// rdar://13660038
+int tryTo(int (*f)(void)) {
+ @try {
+ @autoreleasepool {
+ return f();
+ }
+ } @catch (...) {
+ return 0;
+ }
+}
+// CHECK: define i32 @tryTo(i32 ()*
+// CHECK: [[RET:%.*]] = alloca i32,
+// CHECK: [[T0:%.*]] = call i8* @objc_autoreleasePoolPush()
+// CHECK-NEXT: [[T1:%.*]] = load i32 ()** {{%.*}},
+// CHECK-NEXT: [[T2:%.*]] = invoke i32 [[T1]]()
+// CHECK: store i32 [[T2]], i32* [[RET]]
+// CHECK: invoke void @objc_autoreleasePoolPop(i8* [[T0]])
+// CHECK: landingpad { i8*, i32 } personality
+// CHECK-NEXT: catch i8* null
+// CHECK: call i8* @objc_begin_catch
+// CHECK-NEXT: store i32 0, i32* [[RET]]
+// CHECK: call void @objc_end_catch()
More information about the cfe-commits
mailing list