llvm.org GIT mirror llvm / 1a95f98
Preserve the linkage for objc* intrinsics as clang will set them to weak_external in some cases Clang uses weak linkage for objc runtime functions when they are not available on the platform. The intrinsic has this linkage so we just need to pass that on to the runtime call. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@349559 91177308-0d34-0410-b5e6-96231b3b80d8 Pete Cooper 8 months ago
2 changed file(s) with 36 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
6565 // program already contains a function with this name.
6666 Module *M = F.getParent();
6767 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))
68
69 if (Function* Fn = dyn_cast(FCache)) {
70 Fn->setLinkage(F.getLinkage());
71 if (setNonLazyBind && !Fn->isWeakForLinker()) {
72 // If we have Native ARC, set nonlazybind attribute for these APIs for
73 // performance.
7374 Fn->addFnAttr(Attribute::NonLazyBind);
75 }
76 }
7477
7578 for (auto I = F.use_begin(), E = F.use_end(); I != E;) {
7679 auto *CI = dyn_cast(I->getUser());
259259 declare i8* @llvm.objc.autoreleaseReturnValue(i8*)
260260 declare void @llvm.objc.copyWeak(i8**, i8**)
261261 declare void @llvm.objc.destroyWeak(i8**)
262 declare i8* @llvm.objc.initWeak(i8**, i8*)
262 declare extern_weak i8* @llvm.objc.initWeak(i8**, i8*)
263263 declare i8* @llvm.objc.loadWeak(i8**)
264264 declare i8* @llvm.objc.loadWeakRetained(i8**)
265265 declare void @llvm.objc.moveWeak(i8**, i8**)
279279 declare i32 @llvm.objc.sync.enter(i8*)
280280 declare i32 @llvm.objc.sync.exit(i8*)
281281
282 attributes #0 = { nounwind }
283
284 ; CHECK: declare i8* @objc_autorelease(i8*)
285 ; CHECK: declare void @objc_autoreleasePoolPop(i8*)
286 ; CHECK: declare i8* @objc_autoreleasePoolPush()
287 ; CHECK: declare i8* @objc_autoreleaseReturnValue(i8*)
288 ; CHECK: declare void @objc_copyWeak(i8**, i8**)
289 ; CHECK: declare void @objc_destroyWeak(i8**)
290 ; CHECK: declare extern_weak i8* @objc_initWeak(i8**, i8*)
291 ; CHECK: declare i8* @objc_loadWeak(i8**)
292 ; CHECK: declare i8* @objc_loadWeakRetained(i8**)
293 ; CHECK: declare void @objc_moveWeak(i8**, i8**)
282294 ; CHECK: declare void @objc_release(i8*) [[NLB:#[0-9]+]]
283295 ; CHECK: declare i8* @objc_retain(i8*) [[NLB]]
284
296 ; CHECK: declare i8* @objc_retainAutorelease(i8*)
297 ; CHECK: declare i8* @objc_retainAutoreleaseReturnValue(i8*)
298 ; CHECK: declare i8* @objc_retainAutoreleasedReturnValue(i8*)
299 ; CHECK: declare i8* @objc_retainBlock(i8*)
300 ; CHECK: declare void @objc_storeStrong(i8**, i8*)
301 ; CHECK: declare i8* @objc_storeWeak(i8**, i8*)
302 ; CHECK: declare i8* @objc_unsafeClaimAutoreleasedReturnValue(i8*)
303 ; CHECK: declare i8* @objc_retainedObject(i8*)
304 ; CHECK: declare i8* @objc_unretainedObject(i8*)
305 ; CHECK: declare i8* @objc_unretainedPointer(i8*)
306 ; CHECK: declare i8* @objc_retain_autorelease(i8*)
307 ; CHECK: declare i32 @objc_sync_enter(i8*)
308 ; CHECK: declare i32 @objc_sync_exit(i8*)
309
310 ; CHECK: attributes #0 = { nounwind }
285311 ; CHECK: attributes [[NLB]] = { nonlazybind }