summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorXin Tong <trent.xin.tong@gmail.com>2018-10-08 15:12:48 +0000
committerXin Tong <trent.xin.tong@gmail.com>2018-10-08 15:12:48 +0000
commitbfdad33b82b9ac535b33b2783870dffe3bd401f3 (patch)
tree4b10dbc758b6d57656d06b6656ac8d3c3a792ffc /llvm/lib
parent367b4741f4954c9d4013ffcbfb48ca2c535fd6d1 (diff)
downloadbcm5719-llvm-bfdad33b82b9ac535b33b2783870dffe3bd401f3.tar.gz
bcm5719-llvm-bfdad33b82b9ac535b33b2783870dffe3bd401f3.zip
[ThinLTO] Keep non-prevailing (linkonce|weak)_odr symbols live
Summary: If we have a symbol with (linkonce|weak)_odr linkage, we do not want to dead strip it even it is not prevailing. IR level (linkonce|weak)_odr symbol can become non-prevailing when we mix ELF objects and IR objects where the (linkonce|weak)_odr symbol in the ELF object is prevailing and the ones in the IR objects are not. Stripping them will prevent us from doing optimizations with them. By not dead stripping them, We will convert these symbols to available_externally linkage as a result of non-prevailing and eventually dropping them after inlining. I modified cache-prevailing.ll to use linkonce linkage as it is testing whether cache prevailing bit is effective or not, not we should treat linkonce_odr alive or not Reviewers: tejohnson, pcc Subscribers: mehdi_amini, inglorion, eraman, steven_wu, dexonsmith, llvm-commits Differential Revision: https://reviews.llvm.org/D52893 llvm-svn: 343970
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/IPO/FunctionImport.cpp20
1 files changed, 12 insertions, 8 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp
index bc1bbcb1fda..8f8c85e1b18 100644
--- a/llvm/lib/Transforms/IPO/FunctionImport.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp
@@ -741,24 +741,28 @@ void llvm::computeDeadSymbols(
return;
// We only keep live symbols that are known to be non-prevailing if any are
- // available_externally. Those symbols are discarded later in the
- // EliminateAvailableExternally pass and setting them to not-live breaks
- // downstreams users of liveness information (PR36483).
+ // available_externally, linkonceodr, weakodr. Those symbols are discarded
+ // later in the EliminateAvailableExternally pass and setting them to
+ // not-live could break downstreams users of liveness information (PR36483)
+ // or limit optimization opportunities.
if (isPrevailing(VI.getGUID()) == PrevailingType::No) {
- bool AvailableExternally = false;
+ bool KeepAliveLinkage = false;
bool Interposable = false;
for (auto &S : VI.getSummaryList()) {
- if (S->linkage() == GlobalValue::AvailableExternallyLinkage)
- AvailableExternally = true;
+ if (S->linkage() == GlobalValue::AvailableExternallyLinkage ||
+ S->linkage() == GlobalValue::WeakODRLinkage ||
+ S->linkage() == GlobalValue::LinkOnceODRLinkage)
+ KeepAliveLinkage = true;
else if (GlobalValue::isInterposableLinkage(S->linkage()))
Interposable = true;
}
- if (!AvailableExternally)
+ if (!KeepAliveLinkage)
return;
if (Interposable)
- report_fatal_error("Interposable and available_externally symbol");
+ report_fatal_error(
+ "Interposable and available_externally/linkonce_odr/weak_odr symbol");
}
for (auto &S : VI.getSummaryList())
OpenPOWER on IntegriCloud