llvm.org GIT mirror llvm / 4668002
[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 Teresa Johnson 3 years ago
5 changed file(s) with 21 addition(s) and 30 deletion(s). Raw diff Collapse all Expand all
312312 /// of the module. The StringMap makes a copy of and owns inserted strings.
313313 typedef StringMap> ModulePathStringTableTy;
314314
315 /// Map of global value GUID to its summary, used to identify values defined in
316 /// a particular module, and provide efficient access to their summary.
317 typedef std::map GVSummaryMapTy;
318
315319 /// Class to hold module path string table and global value map,
316320 /// and encapsulate methods for operating on them.
317321 class ModuleSummaryIndex {
445449
446450 /// Collect for the given module the list of function it defines
447451 /// (GUID -> Summary).
448 void collectDefinedFunctionsForModule(
449 StringRef ModulePath,
450 std::map &GVSummaryMap) const;
452 void collectDefinedFunctionsForModule(StringRef ModulePath,
453 GVSummaryMapTy &GVSummaryMap) const;
451454
452455 /// Collect for each module the list of Summaries it defines (GUID ->
453456 /// Summary).
454457 void collectDefinedGVSummariesPerModule(
455 StringMap> &
456 ModuleToDefinedGVSummaries) const;
458 StringMap &ModuleToDefinedGVSummaries) const;
457459 };
458460
459461 } // End llvm namespace
1111
1212 #include "llvm/ADT/StringMap.h"
1313 #include "llvm/IR/GlobalValue.h"
14 #include "llvm/IR/ModuleSummaryIndex.h"
1415
1516 #include
1617 #include
2021 class LLVMContext;
2122 class GlobalValueSummary;
2223 class Module;
23 class ModuleSummaryIndex;
2424
2525 /// The function importer is automatically importing function from other modules
2626 /// based on the provided summary informations.
7575 /// is the set of globals that need to be promoted/renamed appropriately.
7676 void ComputeCrossModuleImport(
7777 const ModuleSummaryIndex &Index,
78 const StringMap> &
79 ModuleToDefinedGVSummaries,
78 const StringMap &ModuleToDefinedGVSummaries,
8079 StringMap &ImportLists,
8180 StringMap &ExportLists);
8281
6767 // Collect for the given module the list of function it defines
6868 // (GUID -> Summary).
6969 void ModuleSummaryIndex::collectDefinedFunctionsForModule(
70 StringRef ModulePath,
71 std::map &GVSummaryMap) const {
70 StringRef ModulePath, GVSummaryMapTy &GVSummaryMap) const {
7271 for (auto &GlobalList : *this) {
7372 auto GUID = GlobalList.first;
7473 for (auto &GlobSummary : GlobalList.second) {
8685
8786 // Collect for each module the list of function it defines (GUID -> Summary).
8887 void ModuleSummaryIndex::collectDefinedGVSummariesPerModule(
89 StringMap>
90 &ModuleToDefinedGVSummaries) const {
88 StringMap &ModuleToDefinedGVSummaries) const {
9189 for (auto &GlobalList : *this) {
9290 auto GUID = GlobalList.first;
9391 for (auto &Summary : GlobalList.second) {
186186 static void ResolveODR(
187187 const ModuleSummaryIndex &Index,
188188 const FunctionImporter::ExportSetTy &ExportList,
189 const std::map &DefinedGlobals,
190 StringRef ModuleIdentifier,
189 const GVSummaryMapTy &DefinedGlobals, StringRef ModuleIdentifier,
191190 std::map &ResolvedODR) {
192191 if (Index.modulePaths().size() == 1)
193192 // Nothing to do if we don't have multiple modules
422421 const FunctionImporter::ImportMapTy &ImportList,
423422 const FunctionImporter::ExportSetTy &ExportList,
424423 const std::map &ResolvedODR,
425 const std::map &DefinedFunctions,
424 const GVSummaryMapTy &DefinedFunctions,
426425 const DenseSet &PreservedSymbols) {
427426 if (CachePath.empty())
428427 return;
671670 auto ModuleCount = Index.modulePaths().size();
672671 auto ModuleIdentifier = TheModule.getModuleIdentifier();
673672 // Collect for each module the list of function it defines (GUID -> Summary).
674 StringMap>
675 ModuleToDefinedGVSummaries;
673 StringMap ModuleToDefinedGVSummaries;
676674 Index.collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
677675
678676 // Generate import/export list
704702 auto ModuleCount = Index.modulePaths().size();
705703
706704 // Collect for each module the list of function it defines (GUID -> Summary).
707 StringMap>
708 ModuleToDefinedGVSummaries(ModuleCount);
705 StringMap ModuleToDefinedGVSummaries(ModuleCount);
709706 Index.collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
710707
711708 // Generate import/export list
732729 computeGUIDPreservedSymbols(PreservedSymbols, TMBuilder.TheTriple);
733730
734731 // Collect for each module the list of function it defines (GUID -> Summary).
735 StringMap>
736 ModuleToDefinedGVSummaries(ModuleCount);
732 StringMap ModuleToDefinedGVSummaries(ModuleCount);
737733 Index.collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
738734
739735 // Generate import/export list
814810 auto ModuleCount = Modules.size();
815811
816812 // Collect for each module the list of function it defines (GUID -> Summary).
817 StringMap>
818 ModuleToDefinedGVSummaries(ModuleCount);
813 StringMap ModuleToDefinedGVSummaries(ModuleCount);
819814 Index->collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
820815
821816 // Collect the import/export lists for all modules from the call-graph in the
184184 /// exported from their source module.
185185 static void computeImportForFunction(
186186 const FunctionSummary &Summary, const ModuleSummaryIndex &Index,
187 unsigned Threshold,
188 const std::map &DefinedGVSummaries,
187 unsigned Threshold, const GVSummaryMapTy &DefinedGVSummaries,
189188 SmallVectorImpl &Worklist,
190189 FunctionImporter::ImportMapTy &ImportsForModule,
191190 StringMap *ExportLists = nullptr) {
255254 /// as well as the list of "exports", i.e. the list of symbols referenced from
256255 /// another module (that may require promotion).
257256 static void ComputeImportForModule(
258 const std::map &DefinedGVSummaries,
259 const ModuleSummaryIndex &Index,
257 const GVSummaryMapTy &DefinedGVSummaries, const ModuleSummaryIndex &Index,
260258 FunctionImporter::ImportMapTy &ImportsForModule,
261259 StringMap *ExportLists = nullptr) {
262260 // Worklist contains the list of function imported in this module, for which
298296 /// Compute all the import and export for every module using the Index.
299297 void llvm::ComputeCrossModuleImport(
300298 const ModuleSummaryIndex &Index,
301 const StringMap> &
302 ModuleToDefinedGVSummaries,
299 const StringMap &ModuleToDefinedGVSummaries,
303300 StringMap &ImportLists,
304301 StringMap &ExportLists) {
305302 // For each module that has function defined, compute the import/export lists.
336333
337334 // Collect the list of functions this module defines.
338335 // GUID -> Summary
339 std::map FunctionSummaryMap;
336 GVSummaryMapTy FunctionSummaryMap;
340337 Index.collectDefinedFunctionsForModule(ModulePath, FunctionSummaryMap);
341338
342339 // Compute the import list for this module.