@@ -334,11 +334,11 @@ using EdgeInfo = std::tuple<const FunctionSummary *, unsigned /* Threshold */>;
334
334
335
335
} // anonymous namespace
336
336
337
- FunctionImporter::AddDefinitionStatus
338
- FunctionImporter::addDefinition (ImportMapTy &ImportList, StringRef FromModule,
339
- GlobalValue::GUID GUID) {
337
+ FunctionImporter::ImportMapTy:: AddDefinitionStatus
338
+ FunctionImporter::ImportMapTy:: addDefinition (StringRef FromModule,
339
+ GlobalValue::GUID GUID) {
340
340
auto [It, Inserted] =
341
- ImportList [FromModule].try_emplace (GUID, GlobalValueSummary::Definition);
341
+ ImportMap [FromModule].try_emplace (GUID, GlobalValueSummary::Definition);
342
342
if (Inserted)
343
343
return AddDefinitionStatus::Inserted;
344
344
if (It->second == GlobalValueSummary::Definition)
@@ -347,10 +347,9 @@ FunctionImporter::addDefinition(ImportMapTy &ImportList, StringRef FromModule,
347
347
return AddDefinitionStatus::ChangedToDefinition;
348
348
}
349
349
350
- void FunctionImporter::maybeAddDeclaration (ImportMapTy &ImportList,
351
- StringRef FromModule,
352
- GlobalValue::GUID GUID) {
353
- ImportList[FromModule].try_emplace (GUID, GlobalValueSummary::Declaration);
350
+ void FunctionImporter::ImportMapTy::maybeAddDeclaration (
351
+ StringRef FromModule, GlobalValue::GUID GUID) {
352
+ ImportMap[FromModule].try_emplace (GUID, GlobalValueSummary::Declaration);
354
353
}
355
354
356
355
// / Import globals referenced by a function or other globals that are being
@@ -411,9 +410,8 @@ class GlobalsImporter final {
411
410
412
411
// If there isn't an entry for GUID, insert <GUID, Definition> pair.
413
412
// Otherwise, definition should take precedence over declaration.
414
- if (FunctionImporter::addDefinition (
415
- ImportList, RefSummary->modulePath (), VI.getGUID ()) !=
416
- FunctionImporter::AddDefinitionStatus::Inserted)
413
+ if (ImportList.addDefinition (RefSummary->modulePath (), VI.getGUID ()) !=
414
+ FunctionImporter::ImportMapTy::AddDefinitionStatus::Inserted)
417
415
break ;
418
416
419
417
// Only update stat and exports if we haven't already imported this
@@ -600,8 +598,7 @@ class WorkloadImportsManager : public ModuleImportsManager {
600
598
LLVM_DEBUG (dbgs () << " [Workload][Including]" << VI.name () << " from "
601
599
<< ExportingModule << " : "
602
600
<< Function::getGUID (VI.name ()) << " \n " );
603
- FunctionImporter::addDefinition (ImportList, ExportingModule,
604
- VI.getGUID ());
601
+ ImportList.addDefinition (ExportingModule, VI.getGUID ());
605
602
GVI.onImportingSummary (*GVS);
606
603
if (ExportLists)
607
604
(*ExportLists)[ExportingModule].insert (VI);
@@ -899,8 +896,7 @@ static void computeImportForFunction(
899
896
900
897
// Note `ExportLists` only keeps track of exports due to imported
901
898
// definitions.
902
- FunctionImporter::maybeAddDeclaration (ImportList, DeclSourceModule,
903
- VI.getGUID ());
899
+ ImportList.maybeAddDeclaration (DeclSourceModule, VI.getGUID ());
904
900
}
905
901
// Update with new larger threshold if this was a retry (otherwise
906
902
// we would have already inserted with NewThreshold above). Also
@@ -949,9 +945,8 @@ static void computeImportForFunction(
949
945
950
946
// Try emplace the definition entry, and update stats based on insertion
951
947
// status.
952
- if (FunctionImporter::addDefinition (ImportList, ExportModulePath,
953
- VI.getGUID ()) !=
954
- FunctionImporter::AddDefinitionStatus::NoChange) {
948
+ if (ImportList.addDefinition (ExportModulePath, VI.getGUID ()) !=
949
+ FunctionImporter::ImportMapTy::AddDefinitionStatus::NoChange) {
955
950
NumImportedFunctionsThinLink++;
956
951
if (IsHotCallsite)
957
952
NumImportedHotFunctionsThinLink++;
@@ -1084,7 +1079,7 @@ numGlobalVarSummaries(const ModuleSummaryIndex &Index,
1084
1079
// the number of defined function summaries as output parameter.
1085
1080
static unsigned
1086
1081
numGlobalVarSummaries (const ModuleSummaryIndex &Index,
1087
- FunctionImporter::FunctionsToImportTy &ImportMap,
1082
+ const FunctionImporter::FunctionsToImportTy &ImportMap,
1088
1083
unsigned &DefinedFS) {
1089
1084
unsigned NumGVS = 0 ;
1090
1085
DefinedFS = 0 ;
@@ -1105,9 +1100,9 @@ static bool checkVariableImport(
1105
1100
DenseMap<StringRef, FunctionImporter::ExportSetTy> &ExportLists) {
1106
1101
DenseSet<GlobalValue::GUID> FlattenedImports;
1107
1102
1108
- for (auto &ImportPerModule : ImportLists)
1109
- for (auto &ExportPerModule : ImportPerModule.second )
1110
- for (auto &[GUID, Type] : ExportPerModule.second )
1103
+ for (const auto &ImportPerModule : ImportLists)
1104
+ for (const auto &ExportPerModule : ImportPerModule.second . getImportMap () )
1105
+ for (const auto &[GUID, Type] : ExportPerModule.second )
1111
1106
FlattenedImports.insert (GUID);
1112
1107
1113
1108
// Checks that all GUIDs of read/writeonly vars we see in export lists
@@ -1217,9 +1212,10 @@ void llvm::ComputeCrossModuleImport(
1217
1212
unsigned NumGVS = numGlobalVarSummaries (Index, Exports);
1218
1213
LLVM_DEBUG (dbgs () << " * Module " << ModName << " exports "
1219
1214
<< Exports.size () - NumGVS << " functions and " << NumGVS
1220
- << " vars. Imports from " << ModuleImports.second .size ()
1215
+ << " vars. Imports from "
1216
+ << ModuleImports.second .getImportMap ().size ()
1221
1217
<< " modules.\n " );
1222
- for (auto &Src : ModuleImports.second ) {
1218
+ for (const auto &Src : ModuleImports.second . getImportMap () ) {
1223
1219
auto SrcModName = Src.first ;
1224
1220
unsigned DefinedFS = 0 ;
1225
1221
unsigned NumGVSPerMod =
@@ -1240,8 +1236,8 @@ static void dumpImportListForModule(const ModuleSummaryIndex &Index,
1240
1236
StringRef ModulePath,
1241
1237
FunctionImporter::ImportMapTy &ImportList) {
1242
1238
LLVM_DEBUG (dbgs () << " * Module " << ModulePath << " imports from "
1243
- << ImportList.size () << " modules.\n " );
1244
- for (auto &Src : ImportList) {
1239
+ << ImportList.getImportMap (). size () << " modules.\n " );
1240
+ for (const auto &Src : ImportList. getImportMap () ) {
1245
1241
auto SrcModName = Src.first ;
1246
1242
unsigned DefinedFS = 0 ;
1247
1243
unsigned NumGVSPerMod = numGlobalVarSummaries (Index, Src.second , DefinedFS);
@@ -1306,8 +1302,7 @@ static void ComputeCrossModuleImportForModuleFromIndexForTest(
1306
1302
if (Summary->modulePath () == ModulePath)
1307
1303
continue ;
1308
1304
// Add an entry to provoke importing by thinBackend.
1309
- FunctionImporter::addGUID (ImportList, Summary->modulePath (), GUID,
1310
- Summary->importType ());
1305
+ ImportList.addGUID (Summary->modulePath (), GUID, Summary->importType ());
1311
1306
}
1312
1307
#ifndef NDEBUG
1313
1308
dumpImportListForModule (Index, ModulePath, ImportList);
@@ -1496,7 +1491,7 @@ void llvm::gatherImportedSummariesForModule(
1496
1491
ModuleToSummariesForIndex[std::string (ModulePath)] =
1497
1492
ModuleToDefinedGVSummaries.lookup (ModulePath);
1498
1493
// Include summaries for imports.
1499
- for (const auto &ILI : ImportList) {
1494
+ for (const auto &ILI : ImportList. getImportMap () ) {
1500
1495
auto &SummariesForIndex = ModuleToSummariesForIndex[std::string (ILI.first )];
1501
1496
1502
1497
const auto &DefinedGVSummaries =
@@ -1777,7 +1772,7 @@ Expected<bool> FunctionImporter::importFunctions(
1777
1772
IRMover Mover (DestModule);
1778
1773
// Do the actual import of functions now, one Module at a time
1779
1774
std::set<StringRef> ModuleNameOrderedList;
1780
- for (const auto &FunctionsToImportPerModule : ImportList) {
1775
+ for (const auto &FunctionsToImportPerModule : ImportList. getImportMap () ) {
1781
1776
ModuleNameOrderedList.insert (FunctionsToImportPerModule.first );
1782
1777
}
1783
1778
@@ -1792,8 +1787,9 @@ Expected<bool> FunctionImporter::importFunctions(
1792
1787
1793
1788
for (const auto &Name : ModuleNameOrderedList) {
1794
1789
// Get the module for the import
1795
- const auto &FunctionsToImportPerModule = ImportList.find (Name);
1796
- assert (FunctionsToImportPerModule != ImportList.end ());
1790
+ const auto &FunctionsToImportPerModule =
1791
+ ImportList.getImportMap ().find (Name);
1792
+ assert (FunctionsToImportPerModule != ImportList.getImportMap ().end ());
1797
1793
Expected<std::unique_ptr<Module>> SrcModuleOrErr = ModuleLoader (Name);
1798
1794
if (!SrcModuleOrErr)
1799
1795
return SrcModuleOrErr.takeError ();
0 commit comments