This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG65e57bbed06d: [FunctionImport] Reduce string duplication
(NFC) (authored by tejohnson).
Changed prior to commit:
https://reviews.llvm.org/D156580?vs=545303&id=547359#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156580/new/
https://reviews.llvm.org/D156580
Files:
clang/lib/CodeGen/BackendUtil.cpp
llvm/include/llvm/LTO/LTO.h
llvm/include/llvm/Transforms/IPO/FunctionImport.h
llvm/lib/LTO/LTO.cpp
llvm/lib/LTO/ThinLTOCodeGenerator.cpp
llvm/lib/Transforms/IPO/FunctionImport.cpp
llvm/tools/llvm-link/llvm-link.cpp
Index: llvm/tools/llvm-link/llvm-link.cpp
===================================================================
--- llvm/tools/llvm-link/llvm-link.cpp
+++ llvm/tools/llvm-link/llvm-link.cpp
@@ -323,6 +323,11 @@
};
ModuleLazyLoaderCache ModuleLoaderCache(ModuleLoader);
+ // Owns the filename strings used to key into the ImportList. Normally this is
+ // constructed from the index and the strings are owned by the index, however,
+ // since we are synthesizing this data structure from options we need a cache
+ // to own those strings.
+ StringSet<> FileNameStringCache;
for (const auto &Import : Imports) {
// Identify the requested function and its bitcode source file.
size_t Idx = Import.find(':');
@@ -360,7 +365,8 @@
if (Verbose)
errs() << "Importing " << FunctionName << " from " << FileName << "\n";
- auto &Entry = ImportList[FileName];
+ auto &Entry =
+ ImportList[FileNameStringCache.insert(FileName).first->getKey()];
Entry.insert(F->getGUID());
}
auto CachedModuleLoader = [&](StringRef Identifier) {
Index: llvm/lib/Transforms/IPO/FunctionImport.cpp
===================================================================
--- llvm/lib/Transforms/IPO/FunctionImport.cpp
+++ llvm/lib/Transforms/IPO/FunctionImport.cpp
@@ -272,7 +272,7 @@
function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
IsPrevailing;
FunctionImporter::ImportMapTy &ImportList;
- StringMap<FunctionImporter::ExportSetTy> *const ExportLists;
+ DenseMap<StringRef, FunctionImporter::ExportSetTy> *const ExportLists;
bool shouldImportGlobal(const ValueInfo &VI) {
const auto &GVS = DefinedGVSummaries.find(VI.getGUID());
@@ -357,7 +357,7 @@
function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
IsPrevailing,
FunctionImporter::ImportMapTy &ImportList,
- StringMap<FunctionImporter::ExportSetTy> *ExportLists)
+ DenseMap<StringRef, FunctionImporter::ExportSetTy> *ExportLists)
: Index(Index), DefinedGVSummaries(DefinedGVSummaries),
IsPrevailing(IsPrevailing), ImportList(ImportList),
ExportLists(ExportLists) {}
@@ -403,7 +403,7 @@
isPrevailing,
SmallVectorImpl<EdgeInfo> &Worklist, GlobalsImporter &GVImporter,
FunctionImporter::ImportMapTy &ImportList,
- StringMap<FunctionImporter::ExportSetTy> *ExportLists,
+ DenseMap<StringRef, FunctionImporter::ExportSetTy> *ExportLists,
FunctionImporter::ImportThresholdsTy &ImportThresholds) {
GVImporter.onImportingSummary(Summary);
static int ImportCount = 0;
@@ -576,7 +576,7 @@
isPrevailing,
const ModuleSummaryIndex &Index, StringRef ModName,
FunctionImporter::ImportMapTy &ImportList,
- StringMap<FunctionImporter::ExportSetTy> *ExportLists = nullptr) {
+ DenseMap<StringRef, FunctionImporter::ExportSetTy> *ExportLists = nullptr) {
// Worklist contains the list of function imported in this module, for which
// we will analyse the callees and may import further down the callgraph.
SmallVector<EdgeInfo, 128> Worklist;
@@ -671,10 +671,10 @@
#endif
#ifndef NDEBUG
-static bool
-checkVariableImport(const ModuleSummaryIndex &Index,
- StringMap<FunctionImporter::ImportMapTy> &ImportLists,
- StringMap<FunctionImporter::ExportSetTy> &ExportLists) {
+static bool checkVariableImport(
+ const ModuleSummaryIndex &Index,
+ DenseMap<StringRef, FunctionImporter::ImportMapTy> &ImportLists,
+ DenseMap<StringRef, FunctionImporter::ExportSetTy> &ExportLists) {
DenseSet<GlobalValue::GUID> FlattenedImports;
@@ -702,7 +702,7 @@
for (auto &ExportPerModule : ExportLists)
for (auto &VI : ExportPerModule.second)
if (!FlattenedImports.count(VI.getGUID()) &&
- IsReadOrWriteOnlyVarNeedingImporting(ExportPerModule.first(), VI))
+ IsReadOrWriteOnlyVarNeedingImporting(ExportPerModule.first, VI))
return false;
return true;
@@ -712,19 +712,18 @@
/// Compute all the import and export for every module using the Index.
void llvm::ComputeCrossModuleImport(
const ModuleSummaryIndex &Index,
- const StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries,
+ const DenseMap<StringRef, GVSummaryMapTy> &ModuleToDefinedGVSummaries,
function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
isPrevailing,
- StringMap<FunctionImporter::ImportMapTy> &ImportLists,
- StringMap<FunctionImporter::ExportSetTy> &ExportLists) {
+ DenseMap<StringRef, FunctionImporter::ImportMapTy> &ImportLists,
+ DenseMap<StringRef, FunctionImporter::ExportSetTy> &ExportLists) {
// For each module that has function defined, compute the import/export lists.
for (const auto &DefinedGVSummaries : ModuleToDefinedGVSummaries) {
- auto &ImportList = ImportLists[DefinedGVSummaries.first()];
+ auto &ImportList = ImportLists[DefinedGVSummaries.first];
LLVM_DEBUG(dbgs() << "Computing import for Module '"
- << DefinedGVSummaries.first() << "'\n");
+ << DefinedGVSummaries.first << "'\n");
ComputeImportForModule(DefinedGVSummaries.second, isPrevailing, Index,
- DefinedGVSummaries.first(), ImportList,
- &ExportLists);
+ DefinedGVSummaries.first, ImportList, &ExportLists);
}
// When computing imports we only added the variables and functions being
@@ -735,7 +734,7 @@
for (auto &ELI : ExportLists) {
FunctionImporter::ExportSetTy NewExports;
const auto &DefinedGVSummaries =
- ModuleToDefinedGVSummaries.lookup(ELI.first());
+ ModuleToDefinedGVSummaries.lookup(ELI.first);
for (auto &EI : ELI.second) {
// Find the copy defined in the exporting module so that we can mark the
// values it references in that specific definition as exported.
@@ -783,7 +782,7 @@
LLVM_DEBUG(dbgs() << "Import/Export lists for " << ImportLists.size()
<< " modules:\n");
for (auto &ModuleImports : ImportLists) {
- auto ModName = ModuleImports.first();
+ auto ModName = ModuleImports.first;
auto &Exports = ExportLists[ModName];
unsigned NumGVS = numGlobalVarSummaries(Index, Exports);
LLVM_DEBUG(dbgs() << "* Module " << ModName << " exports "
@@ -791,7 +790,7 @@
<< " vars. Imports from " << ModuleImports.second.size()
<< " modules.\n");
for (auto &Src : ModuleImports.second) {
- auto SrcModName = Src.first();
+ auto SrcModName = Src.first;
unsigned NumGVSPerMod = numGlobalVarSummaries(Index, Src.second);
LLVM_DEBUG(dbgs() << " - " << Src.second.size() - NumGVSPerMod
<< " functions imported from " << SrcModName << "\n");
@@ -809,7 +808,7 @@
LLVM_DEBUG(dbgs() << "* Module " << ModulePath << " imports from "
<< ImportList.size() << " modules.\n");
for (auto &Src : ImportList) {
- auto SrcModName = Src.first();
+ auto SrcModName = Src.first;
unsigned NumGVSPerMod = numGlobalVarSummaries(Index, Src.second);
LLVM_DEBUG(dbgs() << " - " << Src.second.size() - NumGVSPerMod
<< " functions imported from " << SrcModName << "\n");
@@ -1041,7 +1040,7 @@
/// \p ModulePath.
void llvm::gatherImportedSummariesForModule(
StringRef ModulePath,
- const StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries,
+ const DenseMap<StringRef, GVSummaryMapTy> &ModuleToDefinedGVSummaries,
const FunctionImporter::ImportMapTy &ImportList,
std::map<std::string, GVSummaryMapTy> &ModuleToSummariesForIndex) {
// Include all summaries from the importing module.
@@ -1049,10 +1048,9 @@
ModuleToDefinedGVSummaries.lookup(ModulePath);
// Include summaries for imports.
for (const auto &ILI : ImportList) {
- auto &SummariesForIndex =
- ModuleToSummariesForIndex[std::string(ILI.first())];
+ auto &SummariesForIndex = ModuleToSummariesForIndex[std::string(ILI.first)];
const auto &DefinedGVSummaries =
- ModuleToDefinedGVSummaries.lookup(ILI.first());
+ ModuleToDefinedGVSummaries.lookup(ILI.first);
for (const auto &GI : ILI.second) {
const auto &DS = DefinedGVSummaries.find(GI);
assert(DS != DefinedGVSummaries.end() &&
@@ -1327,7 +1325,7 @@
// Do the actual import of functions now, one Module at a time
std::set<StringRef> ModuleNameOrderedList;
for (const auto &FunctionsToImportPerModule : ImportList) {
- ModuleNameOrderedList.insert(FunctionsToImportPerModule.first());
+ ModuleNameOrderedList.insert(FunctionsToImportPerModule.first);
}
for (const auto &Name : ModuleNameOrderedList) {
// Get the module for the import
Index: llvm/lib/LTO/ThinLTOCodeGenerator.cpp
===================================================================
--- llvm/lib/LTO/ThinLTOCodeGenerator.cpp
+++ llvm/lib/LTO/ThinLTOCodeGenerator.cpp
@@ -634,11 +634,12 @@
namespace {
struct IsExported {
- const StringMap<FunctionImporter::ExportSetTy> &ExportLists;
+ const DenseMap<StringRef, FunctionImporter::ExportSetTy> &ExportLists;
const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols;
- IsExported(const StringMap<FunctionImporter::ExportSetTy> &ExportLists,
- const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols)
+ IsExported(
+ const DenseMap<StringRef, FunctionImporter::ExportSetTy> &ExportLists,
+ const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols)
: ExportLists(ExportLists), GUIDPreservedSymbols(GUIDPreservedSymbols) {}
bool operator()(StringRef ModuleIdentifier, ValueInfo VI) const {
@@ -687,7 +688,7 @@
auto ModuleIdentifier = TheModule.getModuleIdentifier();
// Collect for each module the list of function it defines (GUID -> Summary).
- StringMap<GVSummaryMapTy> ModuleToDefinedGVSummaries;
+ DenseMap<StringRef, GVSummaryMapTy> ModuleToDefinedGVSummaries;
Index.collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
// Convert the preserved symbols set from string to GUID
@@ -705,8 +706,8 @@
computePrevailingCopies(Index, PrevailingCopy);
// Generate import/export list
- StringMap<FunctionImporter::ImportMapTy> ImportLists(ModuleCount);
- StringMap<FunctionImporter::ExportSetTy> ExportLists(ModuleCount);
+ DenseMap<StringRef, FunctionImporter::ImportMapTy> ImportLists(ModuleCount);
+ DenseMap<StringRef, FunctionImporter::ExportSetTy> ExportLists(ModuleCount);
ComputeCrossModuleImport(Index, ModuleToDefinedGVSummaries,
IsPrevailing(PrevailingCopy), ImportLists,
ExportLists);
@@ -740,7 +741,7 @@
auto ModuleCount = Index.modulePaths().size();
// Collect for each module the list of function it defines (GUID -> Summary).
- StringMap<GVSummaryMapTy> ModuleToDefinedGVSummaries(ModuleCount);
+ DenseMap<StringRef, GVSummaryMapTy> ModuleToDefinedGVSummaries(ModuleCount);
Index.collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
// Convert the preserved symbols set from string to GUID
@@ -757,8 +758,8 @@
computePrevailingCopies(Index, PrevailingCopy);
// Generate import/export list
- StringMap<FunctionImporter::ImportMapTy> ImportLists(ModuleCount);
- StringMap<FunctionImporter::ExportSetTy> ExportLists(ModuleCount);
+ DenseMap<StringRef, FunctionImporter::ImportMapTy> ImportLists(ModuleCount);
+ DenseMap<StringRef, FunctionImporter::ExportSetTy> ExportLists(ModuleCount);
ComputeCrossModuleImport(Index, ModuleToDefinedGVSummaries,
IsPrevailing(PrevailingCopy), ImportLists,
ExportLists);
@@ -780,7 +781,7 @@
auto ModuleIdentifier = TheModule.getModuleIdentifier();
// Collect for each module the list of function it defines (GUID -> Summary).
- StringMap<GVSummaryMapTy> ModuleToDefinedGVSummaries(ModuleCount);
+ DenseMap<StringRef, GVSummaryMapTy> ModuleToDefinedGVSummaries(ModuleCount);
Index.collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
// Convert the preserved symbols set from string to GUID
@@ -797,8 +798,8 @@
computePrevailingCopies(Index, PrevailingCopy);
// Generate import/export list
- StringMap<FunctionImporter::ImportMapTy> ImportLists(ModuleCount);
- StringMap<FunctionImporter::ExportSetTy> ExportLists(ModuleCount);
+ DenseMap<StringRef, FunctionImporter::ImportMapTy> ImportLists(ModuleCount);
+ DenseMap<StringRef, FunctionImporter::ExportSetTy> ExportLists(ModuleCount);
ComputeCrossModuleImport(Index, ModuleToDefinedGVSummaries,
IsPrevailing(PrevailingCopy), ImportLists,
ExportLists);
@@ -818,7 +819,7 @@
auto ModuleIdentifier = TheModule.getModuleIdentifier();
// Collect for each module the list of function it defines (GUID -> Summary).
- StringMap<GVSummaryMapTy> ModuleToDefinedGVSummaries(ModuleCount);
+ DenseMap<StringRef, GVSummaryMapTy> ModuleToDefinedGVSummaries(ModuleCount);
Index.collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
// Convert the preserved symbols set from string to GUID
@@ -835,8 +836,8 @@
computePrevailingCopies(Index, PrevailingCopy);
// Generate import/export list
- StringMap<FunctionImporter::ImportMapTy> ImportLists(ModuleCount);
- StringMap<FunctionImporter::ExportSetTy> ExportLists(ModuleCount);
+ DenseMap<StringRef, FunctionImporter::ImportMapTy> ImportLists(ModuleCount);
+ DenseMap<StringRef, FunctionImporter::ExportSetTy> ExportLists(ModuleCount);
ComputeCrossModuleImport(Index, ModuleToDefinedGVSummaries,
IsPrevailing(PrevailingCopy), ImportLists,
ExportLists);
@@ -871,7 +872,7 @@
addUsedSymbolToPreservedGUID(File, GUIDPreservedSymbols);
// Collect for each module the list of function it defines (GUID -> Summary).
- StringMap<GVSummaryMapTy> ModuleToDefinedGVSummaries(ModuleCount);
+ DenseMap<StringRef, GVSummaryMapTy> ModuleToDefinedGVSummaries(ModuleCount);
Index.collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
// Compute "dead" symbols, we don't want to import/export these!
@@ -882,8 +883,8 @@
computePrevailingCopies(Index, PrevailingCopy);
// Generate import/export list
- StringMap<FunctionImporter::ImportMapTy> ImportLists(ModuleCount);
- StringMap<FunctionImporter::ExportSetTy> ExportLists(ModuleCount);
+ DenseMap<StringRef, FunctionImporter::ImportMapTy> ImportLists(ModuleCount);
+ DenseMap<StringRef, FunctionImporter::ExportSetTy> ExportLists(ModuleCount);
ComputeCrossModuleImport(Index, ModuleToDefinedGVSummaries,
IsPrevailing(PrevailingCopy), ImportLists,
ExportLists);
@@ -1033,7 +1034,7 @@
auto ModuleCount = Modules.size();
// Collect for each module the list of function it defines (GUID -> Summary).
- StringMap<GVSummaryMapTy> ModuleToDefinedGVSummaries(ModuleCount);
+ DenseMap<StringRef, GVSummaryMapTy> ModuleToDefinedGVSummaries(ModuleCount);
Index->collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
// Convert the preserved symbols set from string to GUID, this is needed for
@@ -1079,8 +1080,8 @@
// Collect the import/export lists for all modules from the call-graph in the
// combined index.
- StringMap<FunctionImporter::ImportMapTy> ImportLists(ModuleCount);
- StringMap<FunctionImporter::ExportSetTy> ExportLists(ModuleCount);
+ DenseMap<StringRef, FunctionImporter::ImportMapTy> ImportLists(ModuleCount);
+ DenseMap<StringRef, FunctionImporter::ExportSetTy> ExportLists(ModuleCount);
ComputeCrossModuleImport(*Index, ModuleToDefinedGVSummaries,
IsPrevailing(PrevailingCopy), ImportLists,
ExportLists);
Index: llvm/lib/LTO/LTO.cpp
===================================================================
--- llvm/lib/LTO/LTO.cpp
+++ llvm/lib/LTO/LTO.cpp
@@ -178,7 +178,7 @@
ImportMapIteratorTy ModIt;
const ModuleSummaryIndex::ModuleInfo *ModInfo;
- StringRef getIdentifier() const { return ModIt->getKey(); }
+ StringRef getIdentifier() const { return ModIt->getFirst(); }
const FunctionImporter::FunctionsToImportTy &getFunctions() const {
return ModIt->second;
}
@@ -191,7 +191,7 @@
for (ImportMapIteratorTy It = ImportList.begin(); It != ImportList.end();
++It) {
- ImportModulesVector.push_back({It, Index.getModule(It->getKey())});
+ ImportModulesVector.push_back({It, Index.getModule(It->getFirst())});
}
// Order using module hash, to be both independent of module name and
// module order.
@@ -1362,14 +1362,15 @@
protected:
const Config &Conf;
ModuleSummaryIndex &CombinedIndex;
- const StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries;
+ const DenseMap<StringRef, GVSummaryMapTy> &ModuleToDefinedGVSummaries;
lto::IndexWriteCallback OnWrite;
bool ShouldEmitImportsFiles;
public:
- ThinBackendProc(const Config &Conf, ModuleSummaryIndex &CombinedIndex,
- const StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries,
- lto::IndexWriteCallback OnWrite, bool ShouldEmitImportsFiles)
+ ThinBackendProc(
+ const Config &Conf, ModuleSummaryIndex &CombinedIndex,
+ const DenseMap<StringRef, GVSummaryMapTy> &ModuleToDefinedGVSummaries,
+ lto::IndexWriteCallback OnWrite, bool ShouldEmitImportsFiles)
: Conf(Conf), CombinedIndex(CombinedIndex),
ModuleToDefinedGVSummaries(ModuleToDefinedGVSummaries),
OnWrite(OnWrite), ShouldEmitImportsFiles(ShouldEmitImportsFiles) {}
@@ -1426,7 +1427,7 @@
InProcessThinBackend(
const Config &Conf, ModuleSummaryIndex &CombinedIndex,
ThreadPoolStrategy ThinLTOParallelism,
- const StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries,
+ const DenseMap<StringRef, GVSummaryMapTy> &ModuleToDefinedGVSummaries,
AddStreamFn AddStream, FileCache Cache, lto::IndexWriteCallback OnWrite,
bool ShouldEmitIndexFiles, bool ShouldEmitImportsFiles)
: ThinBackendProc(Conf, CombinedIndex, ModuleToDefinedGVSummaries,
@@ -1548,13 +1549,15 @@
lto::IndexWriteCallback OnWrite,
bool ShouldEmitIndexFiles,
bool ShouldEmitImportsFiles) {
- return [=](const Config &Conf, ModuleSummaryIndex &CombinedIndex,
- const StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries,
- AddStreamFn AddStream, FileCache Cache) {
- return std::make_unique<InProcessThinBackend>(
- Conf, CombinedIndex, Parallelism, ModuleToDefinedGVSummaries, AddStream,
- Cache, OnWrite, ShouldEmitIndexFiles, ShouldEmitImportsFiles);
- };
+ return
+ [=](const Config &Conf, ModuleSummaryIndex &CombinedIndex,
+ const DenseMap<StringRef, GVSummaryMapTy> &ModuleToDefinedGVSummaries,
+ AddStreamFn AddStream, FileCache Cache) {
+ return std::make_unique<InProcessThinBackend>(
+ Conf, CombinedIndex, Parallelism, ModuleToDefinedGVSummaries,
+ AddStream, Cache, OnWrite, ShouldEmitIndexFiles,
+ ShouldEmitImportsFiles);
+ };
}
// Given the original \p Path to an output file, replace any path
@@ -1584,7 +1587,7 @@
public:
WriteIndexesThinBackend(
const Config &Conf, ModuleSummaryIndex &CombinedIndex,
- const StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries,
+ const DenseMap<StringRef, GVSummaryMapTy> &ModuleToDefinedGVSummaries,
std::string OldPrefix, std::string NewPrefix,
std::string NativeObjectPrefix, bool ShouldEmitImportsFiles,
raw_fd_ostream *LinkedObjectsFile, lto::IndexWriteCallback OnWrite)
@@ -1632,13 +1635,15 @@
std::string OldPrefix, std::string NewPrefix,
std::string NativeObjectPrefix, bool ShouldEmitImportsFiles,
raw_fd_ostream *LinkedObjectsFile, IndexWriteCallback OnWrite) {
- return [=](const Config &Conf, ModuleSummaryIndex &CombinedIndex,
- const StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries,
- AddStreamFn AddStream, FileCache Cache) {
- return std::make_unique<WriteIndexesThinBackend>(
- Conf, CombinedIndex, ModuleToDefinedGVSummaries, OldPrefix, NewPrefix,
- NativeObjectPrefix, ShouldEmitImportsFiles, LinkedObjectsFile, OnWrite);
- };
+ return
+ [=](const Config &Conf, ModuleSummaryIndex &CombinedIndex,
+ const DenseMap<StringRef, GVSummaryMapTy> &ModuleToDefinedGVSummaries,
+ AddStreamFn AddStream, FileCache Cache) {
+ return std::make_unique<WriteIndexesThinBackend>(
+ Conf, CombinedIndex, ModuleToDefinedGVSummaries, OldPrefix,
+ NewPrefix, NativeObjectPrefix, ShouldEmitImportsFiles,
+ LinkedObjectsFile, OnWrite);
+ };
}
Error LTO::runThinLTO(AddStreamFn AddStream, FileCache Cache,
@@ -1664,8 +1669,8 @@
// Collect for each module the list of function it defines (GUID ->
// Summary).
- StringMap<GVSummaryMapTy>
- ModuleToDefinedGVSummaries(ThinLTO.ModuleMap.size());
+ DenseMap<StringRef, GVSummaryMapTy> ModuleToDefinedGVSummaries(
+ ThinLTO.ModuleMap.size());
ThinLTO.CombinedIndex.collectDefinedGVSummariesPerModule(
ModuleToDefinedGVSummaries);
// Create entries for any modules that didn't have any GV summaries
@@ -1682,9 +1687,9 @@
// Synthesize entry counts for functions in the CombinedIndex.
computeSyntheticCounts(ThinLTO.CombinedIndex);
- StringMap<FunctionImporter::ImportMapTy> ImportLists(
+ DenseMap<StringRef, FunctionImporter::ImportMapTy> ImportLists(
ThinLTO.ModuleMap.size());
- StringMap<FunctionImporter::ExportSetTy> ExportLists(
+ DenseMap<StringRef, FunctionImporter::ExportSetTy> ExportLists(
ThinLTO.ModuleMap.size());
StringMap<std::map<GlobalValue::GUID, GlobalValue::LinkageTypes>> ResolvedODR;
Index: llvm/include/llvm/Transforms/IPO/FunctionImport.h
===================================================================
--- llvm/include/llvm/Transforms/IPO/FunctionImport.h
+++ llvm/include/llvm/Transforms/IPO/FunctionImport.h
@@ -94,8 +94,11 @@
/// The map contains an entry for every module to import from, the key being
/// the module identifier to pass to the ModuleLoader. The value is the set of
- /// functions to import.
- using ImportMapTy = StringMap<FunctionsToImportTy>;
+ /// functions to import. The module identifier strings must be owned
+ /// elsewhere, typically by the in-memory ModuleSummaryIndex the importing
+ /// decisions are made from (the module path for each summary is owned by the
+ /// index's module path string table).
+ using ImportMapTy = DenseMap<StringRef, FunctionsToImportTy>;
/// The set contains an entry for every global value the module exports.
using ExportSetTy = DenseSet<ValueInfo>;
@@ -147,13 +150,18 @@
/// \p ExportLists contains for each Module the set of globals (GUID) that will
/// be imported by another module, or referenced by such a function. I.e. this
/// is the set of globals that need to be promoted/renamed appropriately.
+///
+/// The module identifier strings that are the keys of the above two maps
+/// are owned by the in-memory ModuleSummaryIndex the importing decisions
+/// are made from (the module path for each summary is owned by the index's
+/// module path string table).
void ComputeCrossModuleImport(
const ModuleSummaryIndex &Index,
- const StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries,
+ const DenseMap<StringRef, GVSummaryMapTy> &ModuleToDefinedGVSummaries,
function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
isPrevailing,
- StringMap<FunctionImporter::ImportMapTy> &ImportLists,
- StringMap<FunctionImporter::ExportSetTy> &ExportLists);
+ DenseMap<StringRef, FunctionImporter::ImportMapTy> &ImportLists,
+ DenseMap<StringRef, FunctionImporter::ExportSetTy> &ExportLists);
/// Compute all the imports for the given module using the Index.
///
@@ -225,7 +233,7 @@
/// stable order for bitcode emission.
void gatherImportedSummariesForModule(
StringRef ModulePath,
- const StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries,
+ const DenseMap<StringRef, GVSummaryMapTy> &ModuleToDefinedGVSummaries,
const FunctionImporter::ImportMapTy &ImportList,
std::map<std::string, GVSummaryMapTy> &ModuleToSummariesForIndex);
Index: llvm/include/llvm/LTO/LTO.h
===================================================================
--- llvm/include/llvm/LTO/LTO.h
+++ llvm/include/llvm/LTO/LTO.h
@@ -196,7 +196,7 @@
/// create a ThinBackend using one of the create*ThinBackend() functions below.
using ThinBackend = std::function<std::unique_ptr<ThinBackendProc>(
const Config &C, ModuleSummaryIndex &CombinedIndex,
- StringMap<GVSummaryMapTy> &ModuleToDefinedGVSummaries,
+ DenseMap<StringRef, GVSummaryMapTy> &ModuleToDefinedGVSummaries,
AddStreamFn AddStream, FileCache Cache)>;
/// This ThinBackend runs the individual backend jobs in-process.
Index: clang/lib/CodeGen/BackendUtil.cpp
===================================================================
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -1169,7 +1169,7 @@
const clang::TargetOptions &TOpts, const LangOptions &LOpts,
std::unique_ptr<raw_pwrite_stream> OS, std::string SampleProfile,
std::string ProfileRemapping, BackendAction Action) {
- StringMap<DenseMap<GlobalValue::GUID, GlobalValueSummary *>>
+ DenseMap<StringRef, DenseMap<GlobalValue::GUID, GlobalValueSummary *>>
ModuleToDefinedGVSummaries;
CombinedIndex->collectDefinedGVSummariesPerModule(ModuleToDefinedGVSummaries);
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits