diff options
| author | Teresa Johnson <tejohnson@google.com> | 2016-12-15 23:50:06 +0000 |
|---|---|---|
| committer | Teresa Johnson <tejohnson@google.com> | 2016-12-15 23:50:06 +0000 |
| commit | 19f2aa78910110a580c1bba80a0b39596be71879 (patch) | |
| tree | ac054eae8178703a49ddd43e582229269be8fc40 /llvm/lib | |
| parent | 67e979e086a6d452f0d69183b3cfc8ac74b3cf2e (diff) | |
| download | bcm5719-llvm-19f2aa78910110a580c1bba80a0b39596be71879.tar.gz bcm5719-llvm-19f2aa78910110a580c1bba80a0b39596be71879.zip | |
[ThinLTO] Thin link efficiency improvement: don't re-export globals (NFC)
Summary:
We were reinvoking exportGlobalInModule numerous times redundantly.
No need to re-export globals referenced by a global that was already
imported from its module. This resulted in a large speedup in the thin
link for a big application, particularly when importing aggressiveness
was cranked up.
Reviewers: mehdi_amini
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D27687
llvm-svn: 289896
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Transforms/IPO/FunctionImport.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp index 799d402d6e4..7875db2796a 100644 --- a/llvm/lib/Transforms/IPO/FunctionImport.cpp +++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp @@ -338,6 +338,7 @@ static void computeImportForFunction( << ProcessedThreshold << "\n"); continue; } + bool PreviouslyImported = ProcessedThreshold != 0; // Mark this function as imported in this module, with the current Threshold ProcessedThreshold = AdjThreshold; @@ -345,15 +346,18 @@ static void computeImportForFunction( if (ExportLists) { auto &ExportList = (*ExportLists)[ExportModulePath]; ExportList.insert(GUID); - // Mark all functions and globals referenced by this function as exported - // to the outside if they are defined in the same source module. - for (auto &Edge : ResolvedCalleeSummary->calls()) { - auto CalleeGUID = Edge.first.getGUID(); - exportGlobalInModule(Index, ExportModulePath, CalleeGUID, ExportList); - } - for (auto &Ref : ResolvedCalleeSummary->refs()) { - auto GUID = Ref.getGUID(); - exportGlobalInModule(Index, ExportModulePath, GUID, ExportList); + if (!PreviouslyImported) { + // This is the first time this function was exported from its source + // module, so mark all functions and globals it references as exported + // to the outside if they are defined in the same source module. + for (auto &Edge : ResolvedCalleeSummary->calls()) { + auto CalleeGUID = Edge.first.getGUID(); + exportGlobalInModule(Index, ExportModulePath, CalleeGUID, ExportList); + } + for (auto &Ref : ResolvedCalleeSummary->refs()) { + auto GUID = Ref.getGUID(); + exportGlobalInModule(Index, ExportModulePath, GUID, ExportList); + } } } |

