summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2016-11-14 19:21:41 +0000
committerTeresa Johnson <tejohnson@google.com>2016-11-14 19:21:41 +0000
commit4fef68cb8d24137cf2d7d399d9e6efd478714acc (patch)
tree655ff56e4656f3b07a77ea03c1bdd08cea3d96bf /llvm/lib/Transforms/IPO
parent6c77811a291055b27679df87756752ea3d654b55 (diff)
downloadbcm5719-llvm-4fef68cb8d24137cf2d7d399d9e6efd478714acc.tar.gz
bcm5719-llvm-4fef68cb8d24137cf2d7d399d9e6efd478714acc.zip
[ThinLTO] Only promote exported locals as marked in index
Summary: We have always speculatively promoted all renamable local values (except const non-address taken variables) for both the exporting and importing module. We would then internalize them back based on the ThinLink results if they weren't actually exported. This is inefficient, and results in unnecessary renames. It also meant we had to check the non-renamability of a value in the summary, which was already checked during function importing analysis in the ThinLink. Made renameModuleForThinLTO (which does the promotion/renaming) instead use the index when exporting, to avoid unnecessary renames/promotions. For importing modules, we can simply promoted all values as any local we import by definition is exported and needs promotion. This required changes to the method used by the FunctionImport pass (only invoked from 'opt' for testing) and when invoked from llvm-link, since neither does a ThinLink. We simply conservatively mark all locals in the index as promoted, which preserves the current aggressive promotion behavior. I also needed to change an llvm-lto based test where we had previously been aggressively promoting values that weren't importable (aliasees), but now will not promote. Reviewers: mehdi_amini Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D26467 llvm-svn: 286871
Diffstat (limited to 'llvm/lib/Transforms/IPO')
-rw-r--r--llvm/lib/Transforms/IPO/FunctionImport.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp
index 68626c02038..25dd2f0c323 100644
--- a/llvm/lib/Transforms/IPO/FunctionImport.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp
@@ -770,6 +770,17 @@ static bool doImportingForModule(Module &M, const ModuleSummaryIndex *Index) {
ComputeCrossModuleImportForModule(M.getModuleIdentifier(), *Index,
ImportList);
+ // Conservatively mark all internal values as promoted. This interface is
+ // only used when doing importing via the function importing pass. The pass
+ // is only enabled when testing importing via the 'opt' tool, which does
+ // not do the ThinLink that would normally determine what values to promote.
+ for (auto &I : *Index) {
+ for (auto &S : I.second) {
+ if (GlobalValue::isLocalLinkage(S->linkage()))
+ S->setLinkage(GlobalValue::ExternalLinkage);
+ }
+ }
+
// Next we need to promote to global scope and rename any local values that
// are potentially exported to other modules.
if (renameModuleForThinLTO(M, *Index, nullptr)) {
OpenPOWER on IntegriCloud