[cfe-commits] r161448 - in /cfe/trunk: lib/CodeGen/CGObjC.cpp test/CodeGenObjC/arc.m
Fariborz Jahanian
fjahanian at apple.com
Tue Aug 7 14:30:31 PDT 2012
Author: fjahanian
Date: Tue Aug 7 16:30:31 2012
New Revision: 161448
URL: http://llvm.org/viewvc/llvm-project?rev=161448&view=rev
Log:
objc-arc: set nonlazybind attribute on objc_retain/
objc_release for performance for these most often
called APIs. // rdar://12040837
Modified:
cfe/trunk/lib/CodeGen/CGObjC.cpp
cfe/trunk/test/CodeGenObjC/arc.m
Modified: cfe/trunk/lib/CodeGen/CGObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGObjC.cpp?rev=161448&r1=161447&r2=161448&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGObjC.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGObjC.cpp Tue Aug 7 16:30:31 2012
@@ -1696,9 +1696,13 @@
// 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 (!CGM.getLangOpts().ObjCRuntime.hasARC())
- if (llvm::Function *f = dyn_cast<llvm::Function>(fn))
+ if (llvm::Function *f = dyn_cast<llvm::Function>(fn)) {
+ if (!CGM.getLangOpts().ObjCRuntime.hasARC())
f->setLinkage(llvm::Function::ExternalWeakLinkage);
+ // set nonlazybind attribute for these APIs for performance.
+ if (fnName == "objc_retain" || fnName == "objc_release")
+ f->addFnAttr(llvm::Attribute::NonLazyBind);
+ }
return fn;
}
Modified: cfe/trunk/test/CodeGenObjC/arc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc.m?rev=161448&r1=161447&r2=161448&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/arc.m (original)
+++ cfe/trunk/test/CodeGenObjC/arc.m Tue Aug 7 16:30:31 2012
@@ -9,6 +9,9 @@
// CHECK-NEXT: [[TMP:%.*]] = load i8** [[X]]
// CHECK-NEXT: call void @objc_release(i8* [[TMP]])
// CHECK-NEXT: ret void
+// rdar://12040837
+ // CHECK: declare extern_weak i8* @objc_retain(i8*) nonlazybind
+ // CHECK: declare extern_weak void @objc_release(i8*) nonlazybind
}
// CHECK: define i8* @test1(i8*
More information about the cfe-commits
mailing list