diff options
author | Pete Cooper <peter_cooper@apple.com> | 2018-12-18 22:42:08 +0000 |
---|---|---|
committer | Pete Cooper <peter_cooper@apple.com> | 2018-12-18 22:42:08 +0000 |
commit | a3e0be109c414e29404179b02d33b0a9ffac6710 (patch) | |
tree | a4759cf909f028766831d554d216bcb6cfec88fb /llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp | |
parent | d0ffdf87820a05d5aa2677072a1f940b385f62ac (diff) | |
download | bcm5719-llvm-a3e0be109c414e29404179b02d33b0a9ffac6710.tar.gz bcm5719-llvm-a3e0be109c414e29404179b02d33b0a9ffac6710.zip |
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.
llvm-svn: 349559
Diffstat (limited to 'llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp')
-rw-r--r-- | llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp b/llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp index 3689dab2331..b0e9ac03612 100644 --- a/llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp +++ b/llvm/lib/CodeGen/PreISelIntrinsicLowering.cpp @@ -66,12 +66,15 @@ 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)) + + if (Function* Fn = dyn_cast<Function>(FCache)) { + Fn->setLinkage(F.getLinkage()); + if (setNonLazyBind && !Fn->isWeakForLinker()) { + // If we have Native ARC, set nonlazybind attribute for these APIs for + // performance. Fn->addFnAttr(Attribute::NonLazyBind); + } + } for (auto I = F.use_begin(), E = F.use_end(); I != E;) { auto *CI = dyn_cast<CallInst>(I->getUser()); |