On platforms which do not support ARC natively, do not mark objc_retain/objc_release as "nonlazybind".

rdar://13108298.
rdar://13129783.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174253 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGObjC.cpp b/lib/CodeGen/CGObjC.cpp
index e861222..d667e1a 100644
--- a/lib/CodeGen/CGObjC.cpp
+++ b/lib/CodeGen/CGObjC.cpp
@@ -1705,16 +1705,18 @@
                                                 StringRef fnName) {
   llvm::Constant *fn = CGM.CreateRuntimeFunction(type, fnName);
 
+  if (llvm::Function *f = dyn_cast<llvm::Function>(fn)) {
   // If the target runtime doesn't naturally support ARC, emit weak
   // references to the runtime support library.  We don't really
   // permit this to fail, but we need a particular relocation style.
-  if (llvm::Function *f = dyn_cast<llvm::Function>(fn)) {
-    if (!CGM.getLangOpts().ObjCRuntime.hasNativeARC())
+    if (!CGM.getLangOpts().ObjCRuntime.hasNativeARC()) {
       f->setLinkage(llvm::Function::ExternalWeakLinkage);
-    // set nonlazybind attribute for these APIs for performance.
-    if (fnName == "objc_retain" || fnName  == "objc_release")
+    } else if (fnName == "objc_retain" || fnName  == "objc_release") {
+      // If we have Native ARC, set nonlazybind attribute for these APIs for
+      // performance.
       f->addFnAttr(llvm::Attribute::NonLazyBind);
   }
+  }
 
   return fn;
 }