diff options
| author | George Rimar <grimar@accesssoftek.com> | 2018-01-17 10:33:05 +0000 |
|---|---|---|
| committer | George Rimar <grimar@accesssoftek.com> | 2018-01-17 10:33:05 +0000 |
| commit | 2421b6fa5c6eb2b827fed3306e4c6a9d49564c86 (patch) | |
| tree | 29e8207db5e024a924115624fb439292a232f816 | |
| parent | f22f3489d76698c1843957972576bfbba515572a (diff) | |
| download | bcm5719-llvm-2421b6fa5c6eb2b827fed3306e4c6a9d49564c86.tar.gz bcm5719-llvm-2421b6fa5c6eb2b827fed3306e4c6a9d49564c86.zip | |
[ThinLTO] - Remove code duplication. NFC.
Refactors 3 copies of isExpected.
Splitted from D42107.
llvm-svn: 322627
| -rw-r--r-- | llvm/lib/LTO/ThinLTOCodeGenerator.cpp | 39 |
1 files changed, 17 insertions, 22 deletions
diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp index abcd8905ad3..692396eac20 100644 --- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp +++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp @@ -607,6 +607,20 @@ std::unique_ptr<ModuleSummaryIndex> ThinLTOCodeGenerator::linkCombinedIndex() { return CombinedIndex; } +static void internalizeAndPromoteInIndex( + const StringMap<FunctionImporter::ExportSetTy> &ExportLists, + const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols, + ModuleSummaryIndex &Index) { + auto isExported = [&](StringRef ModuleIdentifier, GlobalValue::GUID GUID) { + const auto &ExportList = ExportLists.find(ModuleIdentifier); + return (ExportList != ExportLists.end() && + ExportList->second.count(GUID)) || + GUIDPreservedSymbols.count(GUID); + }; + + thinLTOInternalizeAndPromoteInIndex(Index, isExported); +} + /** * Perform promotion and renaming of exported internal functions. * Index is updated to reflect linkage changes from weak resolution. @@ -642,13 +656,7 @@ void ThinLTOCodeGenerator::promote(Module &TheModule, // Promote the exported values in the index, so that they are promoted // in the module. - auto isExported = [&](StringRef ModuleIdentifier, GlobalValue::GUID GUID) { - const auto &ExportList = ExportLists.find(ModuleIdentifier); - return (ExportList != ExportLists.end() && - ExportList->second.count(GUID)) || - GUIDPreservedSymbols.count(GUID); - }; - thinLTOInternalizeAndPromoteInIndex(Index, isExported); + internalizeAndPromoteInIndex(ExportLists, GUIDPreservedSymbols, Index); promoteModule(TheModule, Index); } @@ -762,13 +770,7 @@ void ThinLTOCodeGenerator::internalize(Module &TheModule, return; // Internalization - auto isExported = [&](StringRef ModuleIdentifier, GlobalValue::GUID GUID) { - const auto &ExportList = ExportLists.find(ModuleIdentifier); - return (ExportList != ExportLists.end() && - ExportList->second.count(GUID)) || - GUIDPreservedSymbols.count(GUID); - }; - thinLTOInternalizeAndPromoteInIndex(Index, isExported); + internalizeAndPromoteInIndex(ExportLists, GUIDPreservedSymbols, Index); thinLTOInternalizeModule(TheModule, ModuleToDefinedGVSummaries[ModuleIdentifier]); } @@ -918,17 +920,10 @@ void ThinLTOCodeGenerator::run() { // impacts the caching. resolveWeakForLinkerInIndex(*Index, ResolvedODR); - auto isExported = [&](StringRef ModuleIdentifier, GlobalValue::GUID GUID) { - const auto &ExportList = ExportLists.find(ModuleIdentifier); - return (ExportList != ExportLists.end() && - ExportList->second.count(GUID)) || - GUIDPreservedSymbols.count(GUID); - }; - // Use global summary-based analysis to identify symbols that can be // internalized (because they aren't exported or preserved as per callback). // Changes are made in the index, consumed in the ThinLTO backends. - thinLTOInternalizeAndPromoteInIndex(*Index, isExported); + internalizeAndPromoteInIndex(ExportLists, GUIDPreservedSymbols, *Index); // Make sure that every module has an entry in the ExportLists and // ResolvedODR maps to enable threaded access to these maps below. |

