[ThinLTO] Introduce typedef for commonly-used map type (NFC)

Add a typedef for the std::map<GlobalValue::GUID, GlobalValueSummary *>
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
This commit is contained in:
Teresa Johnson 2016-04-25 21:09:51 +00:00
parent 844a2e9d60
commit 4668002971
5 changed files with 21 additions and 30 deletions

View File

@ -313,6 +313,10 @@ typedef GlobalValueSummaryMapTy::iterator gvsummary_iterator;
/// of the module. The StringMap makes a copy of and owns inserted strings. /// of the module. The StringMap makes a copy of and owns inserted strings.
typedef StringMap<std::pair<uint64_t, ModuleHash>> ModulePathStringTableTy; typedef StringMap<std::pair<uint64_t, ModuleHash>> 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<GlobalValue::GUID, GlobalValueSummary *> GVSummaryMapTy;
/// Class to hold module path string table and global value map, /// Class to hold module path string table and global value map,
/// and encapsulate methods for operating on them. /// and encapsulate methods for operating on them.
class ModuleSummaryIndex { class ModuleSummaryIndex {
@ -446,15 +450,13 @@ public:
/// Collect for the given module the list of function it defines /// Collect for the given module the list of function it defines
/// (GUID -> Summary). /// (GUID -> Summary).
void collectDefinedFunctionsForModule( void collectDefinedFunctionsForModule(StringRef ModulePath,
StringRef ModulePath, GVSummaryMapTy &GVSummaryMap) const;
std::map<GlobalValue::GUID, GlobalValueSummary *> &GVSummaryMap) const;
/// Collect for each module the list of Summaries it defines (GUID -> /// Collect for each module the list of Summaries it defines (GUID ->
/// Summary). /// Summary).
void collectDefinedGVSummariesPerModule( void collectDefinedGVSummariesPerModule(
StringMap<std::map<GlobalValue::GUID, GlobalValueSummary *>> & StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries) const;
ModuleToDefinedGVSummaries) const;
}; };
} // End llvm namespace } // End llvm namespace

View File

@ -12,6 +12,7 @@
#include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringMap.h"
#include "llvm/IR/GlobalValue.h" #include "llvm/IR/GlobalValue.h"
#include "llvm/IR/ModuleSummaryIndex.h"
#include <functional> #include <functional>
#include <map> #include <map>
@ -21,7 +22,6 @@ namespace llvm {
class LLVMContext; class LLVMContext;
class GlobalValueSummary; class GlobalValueSummary;
class Module; class Module;
class ModuleSummaryIndex;
/// The function importer is automatically importing function from other modules /// The function importer is automatically importing function from other modules
/// based on the provided summary informations. /// based on the provided summary informations.
@ -76,8 +76,7 @@ private:
/// is the set of globals that need to be promoted/renamed appropriately. /// is the set of globals that need to be promoted/renamed appropriately.
void ComputeCrossModuleImport( void ComputeCrossModuleImport(
const ModuleSummaryIndex &Index, const ModuleSummaryIndex &Index,
const StringMap<std::map<GlobalValue::GUID, GlobalValueSummary *>> & const StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries,
ModuleToDefinedGVSummaries,
StringMap<FunctionImporter::ImportMapTy> &ImportLists, StringMap<FunctionImporter::ImportMapTy> &ImportLists,
StringMap<FunctionImporter::ExportSetTy> &ExportLists); StringMap<FunctionImporter::ExportSetTy> &ExportLists);

View File

@ -68,8 +68,7 @@ void ModuleSummaryIndex::removeEmptySummaryEntries() {
// Collect for the given module the list of function it defines // Collect for the given module the list of function it defines
// (GUID -> Summary). // (GUID -> Summary).
void ModuleSummaryIndex::collectDefinedFunctionsForModule( void ModuleSummaryIndex::collectDefinedFunctionsForModule(
StringRef ModulePath, StringRef ModulePath, GVSummaryMapTy &GVSummaryMap) const {
std::map<GlobalValue::GUID, GlobalValueSummary *> &GVSummaryMap) const {
for (auto &GlobalList : *this) { for (auto &GlobalList : *this) {
auto GUID = GlobalList.first; auto GUID = GlobalList.first;
for (auto &GlobSummary : GlobalList.second) { for (auto &GlobSummary : GlobalList.second) {
@ -87,8 +86,7 @@ void ModuleSummaryIndex::collectDefinedFunctionsForModule(
// Collect for each module the list of function it defines (GUID -> Summary). // Collect for each module the list of function it defines (GUID -> Summary).
void ModuleSummaryIndex::collectDefinedGVSummariesPerModule( void ModuleSummaryIndex::collectDefinedGVSummariesPerModule(
StringMap<std::map<GlobalValue::GUID, GlobalValueSummary *>> StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries) const {
&ModuleToDefinedGVSummaries) const {
for (auto &GlobalList : *this) { for (auto &GlobalList : *this) {
auto GUID = GlobalList.first; auto GUID = GlobalList.first;
for (auto &Summary : GlobalList.second) { for (auto &Summary : GlobalList.second) {

View File

@ -187,8 +187,7 @@ ResolveODR(const ModuleSummaryIndex &Index,
static void ResolveODR( static void ResolveODR(
const ModuleSummaryIndex &Index, const ModuleSummaryIndex &Index,
const FunctionImporter::ExportSetTy &ExportList, const FunctionImporter::ExportSetTy &ExportList,
const std::map<GlobalValue::GUID, GlobalValueSummary *> &DefinedGlobals, const GVSummaryMapTy &DefinedGlobals, StringRef ModuleIdentifier,
StringRef ModuleIdentifier,
std::map<GlobalValue::GUID, GlobalValue::LinkageTypes> &ResolvedODR) { std::map<GlobalValue::GUID, GlobalValue::LinkageTypes> &ResolvedODR) {
if (Index.modulePaths().size() == 1) if (Index.modulePaths().size() == 1)
// Nothing to do if we don't have multiple modules // Nothing to do if we don't have multiple modules
@ -423,7 +422,7 @@ public:
const FunctionImporter::ImportMapTy &ImportList, const FunctionImporter::ImportMapTy &ImportList,
const FunctionImporter::ExportSetTy &ExportList, const FunctionImporter::ExportSetTy &ExportList,
const std::map<GlobalValue::GUID, GlobalValue::LinkageTypes> &ResolvedODR, const std::map<GlobalValue::GUID, GlobalValue::LinkageTypes> &ResolvedODR,
const std::map<GlobalValue::GUID, GlobalValueSummary *> &DefinedFunctions, const GVSummaryMapTy &DefinedFunctions,
const DenseSet<GlobalValue::GUID> &PreservedSymbols) { const DenseSet<GlobalValue::GUID> &PreservedSymbols) {
if (CachePath.empty()) if (CachePath.empty())
return; return;
@ -672,8 +671,7 @@ void ThinLTOCodeGenerator::promote(Module &TheModule,
auto ModuleCount = Index.modulePaths().size(); auto ModuleCount = Index.modulePaths().size();
auto ModuleIdentifier = TheModule.getModuleIdentifier(); auto ModuleIdentifier = TheModule.getModuleIdentifier();
// Collect for each module the list of function it defines (GUID -> Summary). // Collect for each module the list of function it defines (GUID -> Summary).
StringMap<std::map<GlobalValue::GUID, GlobalValueSummary *>> StringMap<GVSummaryMapTy> ModuleToDefinedGVSummaries;
ModuleToDefinedGVSummaries;
Index.collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries); Index.collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
// Generate import/export list // Generate import/export list
@ -705,8 +703,7 @@ void ThinLTOCodeGenerator::crossModuleImport(Module &TheModule,
auto ModuleCount = Index.modulePaths().size(); auto ModuleCount = Index.modulePaths().size();
// Collect for each module the list of function it defines (GUID -> Summary). // Collect for each module the list of function it defines (GUID -> Summary).
StringMap<std::map<GlobalValue::GUID, GlobalValueSummary *>> StringMap<GVSummaryMapTy> ModuleToDefinedGVSummaries(ModuleCount);
ModuleToDefinedGVSummaries(ModuleCount);
Index.collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries); Index.collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
// Generate import/export list // Generate import/export list
@ -733,8 +730,7 @@ void ThinLTOCodeGenerator::internalize(Module &TheModule,
computeGUIDPreservedSymbols(PreservedSymbols, TMBuilder.TheTriple); computeGUIDPreservedSymbols(PreservedSymbols, TMBuilder.TheTriple);
// Collect for each module the list of function it defines (GUID -> Summary). // Collect for each module the list of function it defines (GUID -> Summary).
StringMap<std::map<GlobalValue::GUID, GlobalValueSummary *>> StringMap<GVSummaryMapTy> ModuleToDefinedGVSummaries(ModuleCount);
ModuleToDefinedGVSummaries(ModuleCount);
Index.collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries); Index.collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
// Generate import/export list // Generate import/export list
@ -815,8 +811,7 @@ void ThinLTOCodeGenerator::run() {
auto ModuleCount = Modules.size(); auto ModuleCount = Modules.size();
// Collect for each module the list of function it defines (GUID -> Summary). // Collect for each module the list of function it defines (GUID -> Summary).
StringMap<std::map<GlobalValue::GUID, GlobalValueSummary *>> StringMap<GVSummaryMapTy> ModuleToDefinedGVSummaries(ModuleCount);
ModuleToDefinedGVSummaries(ModuleCount);
Index->collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries); Index->collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
// Collect the import/export lists for all modules from the call-graph in the // Collect the import/export lists for all modules from the call-graph in the

View File

@ -185,8 +185,7 @@ using EdgeInfo = std::pair<const FunctionSummary *, unsigned /* Threshold */>;
/// exported from their source module. /// exported from their source module.
static void computeImportForFunction( static void computeImportForFunction(
const FunctionSummary &Summary, const ModuleSummaryIndex &Index, const FunctionSummary &Summary, const ModuleSummaryIndex &Index,
unsigned Threshold, unsigned Threshold, const GVSummaryMapTy &DefinedGVSummaries,
const std::map<GlobalValue::GUID, GlobalValueSummary *> &DefinedGVSummaries,
SmallVectorImpl<EdgeInfo> &Worklist, SmallVectorImpl<EdgeInfo> &Worklist,
FunctionImporter::ImportMapTy &ImportsForModule, FunctionImporter::ImportMapTy &ImportsForModule,
StringMap<FunctionImporter::ExportSetTy> *ExportLists = nullptr) { StringMap<FunctionImporter::ExportSetTy> *ExportLists = nullptr) {
@ -256,8 +255,7 @@ static void computeImportForFunction(
/// as well as the list of "exports", i.e. the list of symbols referenced from /// as well as the list of "exports", i.e. the list of symbols referenced from
/// another module (that may require promotion). /// another module (that may require promotion).
static void ComputeImportForModule( static void ComputeImportForModule(
const std::map<GlobalValue::GUID, GlobalValueSummary *> &DefinedGVSummaries, const GVSummaryMapTy &DefinedGVSummaries, const ModuleSummaryIndex &Index,
const ModuleSummaryIndex &Index,
FunctionImporter::ImportMapTy &ImportsForModule, FunctionImporter::ImportMapTy &ImportsForModule,
StringMap<FunctionImporter::ExportSetTy> *ExportLists = nullptr) { StringMap<FunctionImporter::ExportSetTy> *ExportLists = nullptr) {
// Worklist contains the list of function imported in this module, for which // 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. /// Compute all the import and export for every module using the Index.
void llvm::ComputeCrossModuleImport( void llvm::ComputeCrossModuleImport(
const ModuleSummaryIndex &Index, const ModuleSummaryIndex &Index,
const StringMap<std::map<GlobalValue::GUID, GlobalValueSummary *>> & const StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries,
ModuleToDefinedGVSummaries,
StringMap<FunctionImporter::ImportMapTy> &ImportLists, StringMap<FunctionImporter::ImportMapTy> &ImportLists,
StringMap<FunctionImporter::ExportSetTy> &ExportLists) { StringMap<FunctionImporter::ExportSetTy> &ExportLists) {
// For each module that has function defined, compute the import/export lists. // 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. // Collect the list of functions this module defines.
// GUID -> Summary // GUID -> Summary
std::map<GlobalValue::GUID, GlobalValueSummary *> FunctionSummaryMap; GVSummaryMapTy FunctionSummaryMap;
Index.collectDefinedFunctionsForModule(ModulePath, FunctionSummaryMap); Index.collectDefinedFunctionsForModule(ModulePath, FunctionSummaryMap);
// Compute the import list for this module. // Compute the import list for this module.