Index: clang/lib/CodeGen/CGObjC.cpp =================================================================== --- clang/lib/CodeGen/CGObjC.cpp +++ clang/lib/CodeGen/CGObjC.cpp @@ -2059,7 +2059,7 @@ llvm::Value *value, llvm::Type *returnType, llvm::FunctionCallee &fn, - StringRef fnName, bool MayThrow) { + StringRef fnName) { if (isa(value)) return value; @@ -2080,10 +2080,7 @@ // Call the function. llvm::CallBase *Inst = nullptr; - if (MayThrow) - Inst = CGF.EmitCallOrInvoke(fn, value); - else - Inst = CGF.EmitNounwindRuntimeCall(fn, value); + Inst = CGF.EmitCallOrInvoke(fn, value); // Cast the result back to the original type. return CGF.Builder.CreateBitCast(Inst, origType); @@ -2536,7 +2533,7 @@ llvm::Type *resultType) { return emitObjCValueOperation(*this, value, resultType, CGM.getObjCEntrypoints().objc_alloc, - "objc_alloc", /*MayThrow=*/true); + "objc_alloc"); } /// Allocate the given objc object. @@ -2545,14 +2542,14 @@ llvm::Type *resultType) { return emitObjCValueOperation(*this, value, resultType, CGM.getObjCEntrypoints().objc_allocWithZone, - "objc_allocWithZone", /*MayThrow=*/true); + "objc_allocWithZone"); } llvm::Value *CodeGenFunction::EmitObjCAllocInit(llvm::Value *value, llvm::Type *resultType) { return emitObjCValueOperation(*this, value, resultType, CGM.getObjCEntrypoints().objc_alloc_init, - "objc_alloc_init", /*MayThrow=*/true); + "objc_alloc_init"); } /// Produce the code to do a primitive release. @@ -2596,7 +2593,7 @@ return emitObjCValueOperation( *this, value, returnType, CGM.getObjCEntrypoints().objc_autoreleaseRuntimeFunction, - "objc_autorelease", /*MayThrow=*/false); + "objc_autorelease"); } /// Retain the given object, with normal retain semantics. @@ -2605,8 +2602,7 @@ llvm::Type *returnType) { return emitObjCValueOperation( *this, value, returnType, - CGM.getObjCEntrypoints().objc_retainRuntimeFunction, "objc_retain", - /*MayThrow=*/false); + CGM.getObjCEntrypoints().objc_retainRuntimeFunction, "objc_retain"); } /// Release the given object. Index: clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m =================================================================== --- clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m +++ clang/test/CodeGenObjC/convert-messages-to-runtime-calls.m @@ -177,8 +177,8 @@ @class Ety; -// CHECK-LABEL: define {{.*}}void @testException -void testException(NSObject *a) { +// CHECK-LABEL: define {{.*}}void @testException_release +void testException_release(NSObject *a) { // MSGS: {{invoke.*@objc_msgSend}} // CALLS: invoke{{.*}}void @objc_release(i8* % @try { @@ -186,3 +186,23 @@ } @catch (Ety *e) { } } + +// CHECK-LABEL: define {{.*}}void @testException_autorelease +void testException_autorelease(NSObject *a) { + @try { + // MSGS: {{invoke.*@objc_msgSend}} + // CALLS: invoke{{.*}}objc_autorelease(i8* % + [a autorelease]; + } @catch (Ety *e) { + } +} + +// CHECK-LABEL: define {{.*}}void @testException_retain +void testException_retain(NSObject *a) { + @try { + // MSGS: {{invoke.*@objc_msgSend}} + // CALLS: invoke{{.*}}@objc_retain(i8* % + [a retain]; + } @catch (Ety *e) { + } +}