From 46680029712c76f05f13b237165be19fa1394deb Mon Sep 17 00:00:00 2001 From: Teresa Johnson Date: Mon, 25 Apr 2016 21:09:51 +0000 Subject: [PATCH] [ThinLTO] Introduce typedef for commonly-used map type (NFC) Add a typedef for the std::map map that is passed around to identify summaries for values defined in a particular module. This shortens up declarations in a variety of places. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267471 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/IR/ModuleSummaryIndex.h | 12 +++++++----- include/llvm/Transforms/IPO/FunctionImport.h | 5 ++--- lib/IR/ModuleSummaryIndex.cpp | 6 ++---- lib/LTO/ThinLTOCodeGenerator.cpp | 17 ++++++----------- lib/Transforms/IPO/FunctionImport.cpp | 11 ++++------- 5 files changed, 21 insertions(+), 30 deletions(-) diff --git a/include/llvm/IR/ModuleSummaryIndex.h b/include/llvm/IR/ModuleSummaryIndex.h index bc805a1edbf..48f2f7e0b30 100644 --- a/include/llvm/IR/ModuleSummaryIndex.h +++ b/include/llvm/IR/ModuleSummaryIndex.h @@ -313,6 +313,10 @@ typedef GlobalValueSummaryMapTy::iterator gvsummary_iterator; /// of the module. The StringMap makes a copy of and owns inserted strings. typedef StringMap> ModulePathStringTableTy; +/// Map of global value GUID to its summary, used to identify values defined in +/// a particular module, and provide efficient access to their summary. +typedef std::map GVSummaryMapTy; + /// Class to hold module path string table and global value map, /// and encapsulate methods for operating on them. class ModuleSummaryIndex { @@ -446,15 +450,13 @@ public: /// Collect for the given module the list of function it defines /// (GUID -> Summary). - void collectDefinedFunctionsForModule( - StringRef ModulePath, - std::map &GVSummaryMap) const; + void collectDefinedFunctionsForModule(StringRef ModulePath, + GVSummaryMapTy &GVSummaryMap) const; /// Collect for each module the list of Summaries it defines (GUID -> /// Summary). void collectDefinedGVSummariesPerModule( - StringMap> & - ModuleToDefinedGVSummaries) const; + StringMap &ModuleToDefinedGVSummaries) const; }; } // End llvm namespace diff --git a/include/llvm/Transforms/IPO/FunctionImport.h b/include/llvm/Transforms/IPO/FunctionImport.h index 95230ea9e78..154958a22d1 100644 --- a/include/llvm/Transforms/IPO/FunctionImport.h +++ b/include/llvm/Transforms/IPO/FunctionImport.h @@ -12,6 +12,7 @@ #include "llvm/ADT/StringMap.h" #include "llvm/IR/GlobalValue.h" +#include "llvm/IR/ModuleSummaryIndex.h" #include #include @@ -21,7 +22,6 @@ namespace llvm { class LLVMContext; class GlobalValueSummary; class Module; -class ModuleSummaryIndex; /// The function importer is automatically importing function from other modules /// based on the provided summary informations. @@ -76,8 +76,7 @@ private: /// is the set of globals that need to be promoted/renamed appropriately. void ComputeCrossModuleImport( const ModuleSummaryIndex &Index, - const StringMap> & - ModuleToDefinedGVSummaries, + const StringMap &ModuleToDefinedGVSummaries, StringMap &ImportLists, StringMap &ExportLists); diff --git a/lib/IR/ModuleSummaryIndex.cpp b/lib/IR/ModuleSummaryIndex.cpp index 4c122c7241e..6107cf40a08 100644 --- a/lib/IR/ModuleSummaryIndex.cpp +++ b/lib/IR/ModuleSummaryIndex.cpp @@ -68,8 +68,7 @@ void ModuleSummaryIndex::removeEmptySummaryEntries() { // Collect for the given module the list of function it defines // (GUID -> Summary). void ModuleSummaryIndex::collectDefinedFunctionsForModule( - StringRef ModulePath, - std::map &GVSummaryMap) const { + StringRef ModulePath, GVSummaryMapTy &GVSummaryMap) const { for (auto &GlobalList : *this) { auto GUID = GlobalList.first; for (auto &GlobSummary : GlobalList.second) { @@ -87,8 +86,7 @@ void ModuleSummaryIndex::collectDefinedFunctionsForModule( // Collect for each module the list of function it defines (GUID -> Summary). void ModuleSummaryIndex::collectDefinedGVSummariesPerModule( - StringMap> - &ModuleToDefinedGVSummaries) const { + StringMap &ModuleToDefinedGVSummaries) const { for (auto &GlobalList : *this) { auto GUID = GlobalList.first; for (auto &Summary : GlobalList.second) { diff --git a/lib/LTO/ThinLTOCodeGenerator.cpp b/lib/LTO/ThinLTOCodeGenerator.cpp index 21ba1e92a3a..51dcc084b49 100644 --- a/lib/LTO/ThinLTOCodeGenerator.cpp +++ b/lib/LTO/ThinLTOCodeGenerator.cpp @@ -187,8 +187,7 @@ ResolveODR(const ModuleSummaryIndex &Index, static void ResolveODR( const ModuleSummaryIndex &Index, const FunctionImporter::ExportSetTy &ExportList, - const std::map &DefinedGlobals, - StringRef ModuleIdentifier, + const GVSummaryMapTy &DefinedGlobals, StringRef ModuleIdentifier, std::map &ResolvedODR) { if (Index.modulePaths().size() == 1) // Nothing to do if we don't have multiple modules @@ -423,7 +422,7 @@ public: const FunctionImporter::ImportMapTy &ImportList, const FunctionImporter::ExportSetTy &ExportList, const std::map &ResolvedODR, - const std::map &DefinedFunctions, + const GVSummaryMapTy &DefinedFunctions, const DenseSet &PreservedSymbols) { if (CachePath.empty()) return; @@ -672,8 +671,7 @@ void ThinLTOCodeGenerator::promote(Module &TheModule, auto ModuleCount = Index.modulePaths().size(); auto ModuleIdentifier = TheModule.getModuleIdentifier(); // Collect for each module the list of function it defines (GUID -> Summary). - StringMap> - ModuleToDefinedGVSummaries; + StringMap ModuleToDefinedGVSummaries; Index.collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries); // Generate import/export list @@ -705,8 +703,7 @@ void ThinLTOCodeGenerator::crossModuleImport(Module &TheModule, auto ModuleCount = Index.modulePaths().size(); // Collect for each module the list of function it defines (GUID -> Summary). - StringMap> - ModuleToDefinedGVSummaries(ModuleCount); + StringMap ModuleToDefinedGVSummaries(ModuleCount); Index.collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries); // Generate import/export list @@ -733,8 +730,7 @@ void ThinLTOCodeGenerator::internalize(Module &TheModule, computeGUIDPreservedSymbols(PreservedSymbols, TMBuilder.TheTriple); // Collect for each module the list of function it defines (GUID -> Summary). - StringMap> - ModuleToDefinedGVSummaries(ModuleCount); + StringMap ModuleToDefinedGVSummaries(ModuleCount); Index.collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries); // Generate import/export list @@ -815,8 +811,7 @@ void ThinLTOCodeGenerator::run() { auto ModuleCount = Modules.size(); // Collect for each module the list of function it defines (GUID -> Summary). - StringMap> - ModuleToDefinedGVSummaries(ModuleCount); + StringMap ModuleToDefinedGVSummaries(ModuleCount); Index->collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries); // Collect the import/export lists for all modules from the call-graph in the diff --git a/lib/Transforms/IPO/FunctionImport.cpp b/lib/Transforms/IPO/FunctionImport.cpp index b6c8993a6f0..3f0d2624f5d 100644 --- a/lib/Transforms/IPO/FunctionImport.cpp +++ b/lib/Transforms/IPO/FunctionImport.cpp @@ -185,8 +185,7 @@ using EdgeInfo = std::pair; /// exported from their source module. static void computeImportForFunction( const FunctionSummary &Summary, const ModuleSummaryIndex &Index, - unsigned Threshold, - const std::map &DefinedGVSummaries, + unsigned Threshold, const GVSummaryMapTy &DefinedGVSummaries, SmallVectorImpl &Worklist, FunctionImporter::ImportMapTy &ImportsForModule, StringMap *ExportLists = nullptr) { @@ -256,8 +255,7 @@ static void computeImportForFunction( /// as well as the list of "exports", i.e. the list of symbols referenced from /// another module (that may require promotion). static void ComputeImportForModule( - const std::map &DefinedGVSummaries, - const ModuleSummaryIndex &Index, + const GVSummaryMapTy &DefinedGVSummaries, const ModuleSummaryIndex &Index, FunctionImporter::ImportMapTy &ImportsForModule, StringMap *ExportLists = nullptr) { // Worklist contains the list of function imported in this module, for which @@ -299,8 +297,7 @@ static void ComputeImportForModule( /// Compute all the import and export for every module using the Index. void llvm::ComputeCrossModuleImport( const ModuleSummaryIndex &Index, - const StringMap> & - ModuleToDefinedGVSummaries, + const StringMap &ModuleToDefinedGVSummaries, StringMap &ImportLists, StringMap &ExportLists) { // For each module that has function defined, compute the import/export lists. @@ -337,7 +334,7 @@ void llvm::ComputeCrossModuleImportForModule( // Collect the list of functions this module defines. // GUID -> Summary - std::map FunctionSummaryMap; + GVSummaryMapTy FunctionSummaryMap; Index.collectDefinedFunctionsForModule(ModulePath, FunctionSummaryMap); // Compute the import list for this module.