diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2016-07-07 18:31:51 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2016-07-07 18:31:51 +0000 |
commit | 73589f321b88ff6f0896b6beb5d73c40d84ebe41 (patch) | |
tree | a754447d7802d3b8fab00d90a8847d737cc52f22 /llvm/lib/LTO/LTO.cpp | |
parent | bed6779c7a839ed6dab85d0198e105021b63552f (diff) | |
download | llvm-73589f321b88ff6f0896b6beb5d73c40d84ebe41.zip llvm-73589f321b88ff6f0896b6beb5d73c40d84ebe41.tar.gz llvm-73589f321b88ff6f0896b6beb5d73c40d84ebe41.tar.bz2 |
ThinLTO: Do not take into account whether a definition has multiple copies when promoting.
We currently do not touch a symbol's linkage in the case where a definition
has a single copy. However, this code is effectively unnecessary: either
the definition is not exported, in which case the internalize phase sets
its linkage to internal, or it is exported, in which case we need to promote
linkage to weak. Those two cases are already handled by existing code.
I believe that the only real functional change here is in the case where we
have a single definition which does not prevail (e.g. because the definition
in a native object file prevails). In that case we now lower linkage to
available_externally following the existing code path for that case.
As a result we can remove the isExported function parameter from the
thinLTOResolveWeakForLinkerInIndex function.
Differential Revision: http://reviews.llvm.org/D21883
llvm-svn: 274784
Diffstat (limited to 'llvm/lib/LTO/LTO.cpp')
-rw-r--r-- | llvm/lib/LTO/LTO.cpp | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index 11bfc94..10226c4a 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/lib/LTO/LTO.cpp @@ -45,26 +45,17 @@ static void thinLTOResolveWeakForLinkerGUID( DenseSet<GlobalValueSummary *> &GlobalInvolvedWithAlias, function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)> isPrevailing, - function_ref<bool(StringRef, GlobalValue::GUID)> isExported, function_ref<void(StringRef, GlobalValue::GUID, GlobalValue::LinkageTypes)> recordNewLinkage) { - auto HasMultipleCopies = GVSummaryList.size() > 1; - for (auto &S : GVSummaryList) { if (GlobalInvolvedWithAlias.count(S.get())) continue; GlobalValue::LinkageTypes OriginalLinkage = S->linkage(); if (!GlobalValue::isWeakForLinker(OriginalLinkage)) continue; - // We need to emit only one of these, the first module will keep it, + // We need to emit only one of these. The prevailing module will keep it, // but turned into a weak, while the others will drop it when possible. - if (!HasMultipleCopies) { - // Exported Linkonce needs to be promoted to not be discarded. - if (GlobalValue::isLinkOnceLinkage(OriginalLinkage) && - isExported(S->modulePath(), GUID)) - S->setLinkage(GlobalValue::getWeakLinkage( - GlobalValue::isLinkOnceODRLinkage(OriginalLinkage))); - } else if (isPrevailing(GUID, S.get())) { + if (isPrevailing(GUID, S.get())) { if (GlobalValue::isLinkOnceLinkage(OriginalLinkage)) S->setLinkage(GlobalValue::getWeakLinkage( GlobalValue::isLinkOnceODRLinkage(OriginalLinkage))); @@ -89,7 +80,6 @@ void thinLTOResolveWeakForLinkerInIndex( ModuleSummaryIndex &Index, function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)> isPrevailing, - function_ref<bool(StringRef, GlobalValue::GUID)> isExported, function_ref<void(StringRef, GlobalValue::GUID, GlobalValue::LinkageTypes)> recordNewLinkage) { // We won't optimize the globals that are referenced by an alias for now @@ -103,7 +93,7 @@ void thinLTOResolveWeakForLinkerInIndex( for (auto &I : Index) thinLTOResolveWeakForLinkerGUID(I.second, I.first, GlobalInvolvedWithAlias, - isPrevailing, isExported, recordNewLinkage); + isPrevailing, recordNewLinkage); } static void thinLTOInternalizeAndPromoteGUID( |