summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPete Cooper <peter_cooper@apple.com>2018-12-18 22:31:34 +0000
committerPete Cooper <peter_cooper@apple.com>2018-12-18 22:31:34 +0000
commitd0ffdf87820a05d5aa2677072a1f940b385f62ac (patch)
tree0de6300c213d3867e6694f061eceb62e857cab56
parenta01246b7a79fc9b3a5bee9e324181b405f0cb288 (diff)
downloadbcm5719-llvm-d0ffdf87820a05d5aa2677072a1f940b385f62ac.tar.gz
bcm5719-llvm-d0ffdf87820a05d5aa2677072a1f940b385f62ac.zip
Add nonlazybind to objc_retain/objc_release when converting from intrinsics.
For performance reasons, clang set nonlazybind on these functions. Now that we are using intrinsics instead of runtime calls, we should set this attribute when creating the runtime functions. llvm-svn: 349558
-rw-r--r--llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp13
-rw-r--r--llvm/test/Transforms/PreISelIntrinsicLowering/objc-arc.ll5
2 files changed, 15 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp b/llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp
index cd15f6b7fcb..3689dab2331 100644
--- a/llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp
+++ b/llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp
@@ -57,7 +57,8 @@ static bool lowerLoadRelative(Function &F) {
return Changed;
}
-static bool lowerObjCCall(Function &F, const char *NewFn) {
+static bool lowerObjCCall(Function &F, const char *NewFn,
+ bool setNonLazyBind = false) {
if (F.use_empty())
return false;
@@ -65,6 +66,12 @@ static bool lowerObjCCall(Function &F, const char *NewFn) {
// program already contains a function with this name.
Module *M = F.getParent();
Constant* FCache = M->getOrInsertFunction(NewFn, F.getFunctionType());
+
+ // If we have Native ARC, set nonlazybind attribute for these APIs for
+ // performance.
+ if (setNonLazyBind)
+ if (Function* Fn = dyn_cast<Function>(FCache))
+ Fn->addFnAttr(Attribute::NonLazyBind);
for (auto I = F.use_begin(), E = F.use_end(); I != E;) {
auto *CI = dyn_cast<CallInst>(I->getUser());
@@ -125,10 +132,10 @@ static bool lowerIntrinsics(Module &M) {
Changed |= lowerObjCCall(F, "objc_moveWeak");
break;
case Intrinsic::objc_release:
- Changed |= lowerObjCCall(F, "objc_release");
+ Changed |= lowerObjCCall(F, "objc_release", true);
break;
case Intrinsic::objc_retain:
- Changed |= lowerObjCCall(F, "objc_retain");
+ Changed |= lowerObjCCall(F, "objc_retain", true);
break;
case Intrinsic::objc_retainAutorelease:
Changed |= lowerObjCCall(F, "objc_retainAutorelease");
diff --git a/llvm/test/Transforms/PreISelIntrinsicLowering/objc-arc.ll b/llvm/test/Transforms/PreISelIntrinsicLowering/objc-arc.ll
index be852dfe37f..235ef65beee 100644
--- a/llvm/test/Transforms/PreISelIntrinsicLowering/objc-arc.ll
+++ b/llvm/test/Transforms/PreISelIntrinsicLowering/objc-arc.ll
@@ -279,3 +279,8 @@ declare i8* @llvm.objc.unretainedPointer(i8*)
declare i8* @llvm.objc.retain.autorelease(i8*)
declare i32 @llvm.objc.sync.enter(i8*)
declare i32 @llvm.objc.sync.exit(i8*)
+
+; CHECK: declare void @objc_release(i8*) [[NLB:#[0-9]+]]
+; CHECK: declare i8* @objc_retain(i8*) [[NLB]]
+
+; CHECK: attributes [[NLB]] = { nonlazybind }
OpenPOWER on IntegriCloud