[CodeGenObjC] invoke objc_autorelease, objc_retain when necessary

Any of these methods can be overridden, so we need to invoke these functions.

Differential revision: https://reviews.llvm.org/D61957

llvm-svn: 360802
diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp
index 5b67565..8302c10 100644
--- a/clang/lib/CodeGen/CGObjC.cpp
+++ b/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<llvm::ConstantPointerNull>(value))
     return value;
 
@@ -2079,11 +2079,7 @@
   value = CGF.Builder.CreateBitCast(value, CGF.Int8PtrTy);
 
   // Call the function.
-  llvm::CallBase *Inst = nullptr;
-  if (MayThrow)
-    Inst = CGF.EmitCallOrInvoke(fn, value);
-  else
-    Inst = CGF.EmitNounwindRuntimeCall(fn, value);
+  llvm::CallBase *Inst = CGF.EmitCallOrInvoke(fn, value);
 
   // Cast the result back to the original type.
   return CGF.Builder.CreateBitCast(Inst, origType);
@@ -2536,7 +2532,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 +2541,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 +2592,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 +2601,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.