diff options
author | Steven Wu <stevenwu@apple.com> | 2018-02-09 18:34:08 +0000 |
---|---|---|
committer | Steven Wu <stevenwu@apple.com> | 2018-02-09 18:34:08 +0000 |
commit | 33ba93c2b5e6fd8a4d9663a9b50ace9e104ef50d (patch) | |
tree | f305cc9e9bb0e0c0737a5ce2d1af59a4ad88a948 /llvm/lib/Transforms | |
parent | 37a9889309ae533bc5aa9609e108eb8d306f445b (diff) | |
download | bcm5719-llvm-33ba93c2b5e6fd8a4d9663a9b50ace9e104ef50d.tar.gz bcm5719-llvm-33ba93c2b5e6fd8a4d9663a9b50ace9e104ef50d.zip |
[ThinLTO] Teach ThinLTO about auto hide symbols
Summary:
For symbols that has linkonce_odr linkage and unnamed_addr, it can be
auto hide by linker to avoid weak external symbols. Teach ThinLTO to
perform auto hide so it can safely promote linkonce_odr to weak symbols
without breaking this nice property.
Reviewers: tejohnson, mehdi_amini
Reviewed By: tejohnson
Subscribers: inglorion, eraman, rnk, pcc, llvm-commits
Differential Revision: https://reviews.llvm.org/D43130
llvm-svn: 324757
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/IPO/FunctionImport.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp index a5903e27a9d..b92f798c4ab 100644 --- a/llvm/lib/Transforms/IPO/FunctionImport.cpp +++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp @@ -683,6 +683,13 @@ void llvm::thinLTOResolveWeakForLinkerModule( // changed to enable this for aliases. llvm_unreachable("Expected GV to be converted"); } else { + // If the original symbols has global unnamed addr and linkonce_odr linkage, + // it should be an auto hide symbol. Add hidden visibility to the symbol to + // preserve the property. + if (GV.hasLinkOnceODRLinkage() && GV.hasGlobalUnnamedAddr() && + NewLinkage == GlobalValue::WeakODRLinkage) + GV.setVisibility(GlobalValue::HiddenVisibility); + DEBUG(dbgs() << "ODR fixing up linkage for `" << GV.getName() << "` from " << GV.getLinkage() << " to " << NewLinkage << "\n"); GV.setLinkage(NewLinkage); |