diff options
author | Teresa Johnson <tejohnson@google.com> | 2016-12-15 20:48:19 +0000 |
---|---|---|
committer | Teresa Johnson <tejohnson@google.com> | 2016-12-15 20:48:19 +0000 |
commit | 475b51a7000473bd9561e40dfaa20cf6bc2c9cb1 (patch) | |
tree | 1e44a5b7f052c4021a9b17fbcd3efb9ee26b2864 /llvm | |
parent | 0e8a299f190ba206fb58f1bf06c9b195b42734e0 (diff) | |
download | bcm5719-llvm-475b51a7000473bd9561e40dfaa20cf6bc2c9cb1.tar.gz bcm5719-llvm-475b51a7000473bd9561e40dfaa20cf6bc2c9cb1.zip |
[ThinLTO] Thin link efficiency: skip candidate added later with higher threshold (NFC)
Summary:
Thin link efficiency improvement. After adding an importing candidate to
the worklist we might have later added it again with a higher threshold.
Skip it when popped from the worklist if we recorded a higher threshold
than the current worklist entry, it will get processed again at the
higher threshold when that entry is popped.
This required adding the summary's GUID to the worklist, so that it can
be used to query the recorded highest threshold for it when we pop from the
worklist.
Reviewers: mehdi_amini
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D27696
llvm-svn: 289867
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/lib/Transforms/IPO/FunctionImport.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp index c20e59fdb94..947a04bdc32 100644 --- a/llvm/lib/Transforms/IPO/FunctionImport.cpp +++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp @@ -266,7 +266,8 @@ static void exportGlobalInModule(const ModuleSummaryIndex &Index, ExportList.insert(GUID); } -using EdgeInfo = std::pair<const FunctionSummary *, unsigned /* Threshold */>; +using EdgeInfo = std::tuple<const FunctionSummary *, unsigned /* Threshold */, + GlobalValue::GUID>; /// Compute the list of functions to import for a given caller. Mark these /// imported functions and the symbols they reference in their source module as @@ -362,7 +363,7 @@ static void computeImportForFunction( } // Insert the newly imported function to the worklist. - Worklist.emplace_back(ResolvedCalleeSummary, AdjThreshold); + Worklist.emplace_back(ResolvedCalleeSummary, AdjThreshold, GUID); } } @@ -396,8 +397,16 @@ static void ComputeImportForModule( // Process the newly imported functions and add callees to the worklist. while (!Worklist.empty()) { auto FuncInfo = Worklist.pop_back_val(); - auto *Summary = FuncInfo.first; - auto Threshold = FuncInfo.second; + auto *Summary = std::get<0>(FuncInfo); + auto Threshold = std::get<1>(FuncInfo); + auto GUID = std::get<2>(FuncInfo); + + // Check if we later added this summary with a higher threshold. + // If so, skip this entry. + auto ExportModulePath = Summary->modulePath(); + auto &LatestProcessedThreshold = ImportList[ExportModulePath][GUID]; + if (LatestProcessedThreshold > Threshold) + continue; computeImportForFunction(*Summary, Index, Threshold, DefinedGVSummaries, Worklist, ImportList, ExportLists); |