llvm.org GIT mirror llvm / d2c49ab
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@349558 91177308-0d34-0410-b5e6-96231b3b80d8 Pete Cooper 8 months ago
2 changed file(s) with 15 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
5656 return Changed;
5757 }
5858
59 static bool lowerObjCCall(Function &F, const char *NewFn) {
59 static bool lowerObjCCall(Function &F, const char *NewFn,
60 bool setNonLazyBind = false) {
6061 if (F.use_empty())
6162 return false;
6263
6465 // program already contains a function with this name.
6566 Module *M = F.getParent();
6667 Constant* FCache = M->getOrInsertFunction(NewFn, F.getFunctionType());
68
69 // If we have Native ARC, set nonlazybind attribute for these APIs for
70 // performance.
71 if (setNonLazyBind)
72 if (Function* Fn = dyn_cast(FCache))
73 Fn->addFnAttr(Attribute::NonLazyBind);
6774
6875 for (auto I = F.use_begin(), E = F.use_end(); I != E;) {
6976 auto *CI = dyn_cast(I->getUser());
124131 Changed |= lowerObjCCall(F, "objc_moveWeak");
125132 break;
126133 case Intrinsic::objc_release:
127 Changed |= lowerObjCCall(F, "objc_release");
134 Changed |= lowerObjCCall(F, "objc_release", true);
128135 break;
129136 case Intrinsic::objc_retain:
130 Changed |= lowerObjCCall(F, "objc_retain");
137 Changed |= lowerObjCCall(F, "objc_retain", true);
131138 break;
132139 case Intrinsic::objc_retainAutorelease:
133140 Changed |= lowerObjCCall(F, "objc_retainAutorelease");
278278 declare i8* @llvm.objc.retain.autorelease(i8*)
279279 declare i32 @llvm.objc.sync.enter(i8*)
280280 declare i32 @llvm.objc.sync.exit(i8*)
281
282 ; CHECK: declare void @objc_release(i8*) [[NLB:#[0-9]+]]
283 ; CHECK: declare i8* @objc_retain(i8*) [[NLB]]
284
285 ; CHECK: attributes [[NLB]] = { nonlazybind }