diff options
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/IR/ModuleSummaryIndex.cpp | 21 | ||||
-rw-r--r-- | llvm/lib/LTO/LTO.cpp | 8 | ||||
-rw-r--r-- | llvm/lib/LTO/ThinLTOCodeGenerator.cpp | 4 |
4 files changed, 21 insertions, 16 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 101e8eba6b1..df9ab1c496c 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -6147,8 +6147,8 @@ std::error_code ModuleSummaryIndexBitcodeReader::parseModule() { if (!TheIndex) break; if (TheIndex->modulePaths().empty()) - // Does not have any summary emitted. - break; + // We always seed the index with the module. + TheIndex->addModulePath(Buffer->getBufferIdentifier(), 0); if (TheIndex->modulePaths().size() != 1) return error("Don't expect multiple modules defined?"); auto &Hash = TheIndex->modulePaths().begin()->second.second; diff --git a/llvm/lib/IR/ModuleSummaryIndex.cpp b/llvm/lib/IR/ModuleSummaryIndex.cpp index 6107cf40a08..9072f4bc7b1 100644 --- a/llvm/lib/IR/ModuleSummaryIndex.cpp +++ b/llvm/lib/IR/ModuleSummaryIndex.cpp @@ -20,8 +20,17 @@ using namespace llvm; // per-module instances. void ModuleSummaryIndex::mergeFrom(std::unique_ptr<ModuleSummaryIndex> Other, uint64_t NextModuleId) { + if (Other->modulePaths().empty()) + return; + + assert(Other->modulePaths().size() == 1 && + "Can only merge from an single-module index at that time"); + + StringRef OtherModPath = Other->modulePaths().begin()->first(); + StringRef ModPath = addModulePath(OtherModPath, NextModuleId, + Other->getModuleHash(OtherModPath)) + ->first(); - StringRef ModPath; for (auto &OtherGlobalValSummaryLists : *Other) { GlobalValue::GUID ValueGUID = OtherGlobalValSummaryLists.first; GlobalValueSummaryList &List = OtherGlobalValSummaryLists.second; @@ -31,16 +40,6 @@ void ModuleSummaryIndex::mergeFrom(std::unique_ptr<ModuleSummaryIndex> Other, assert(List.size() == 1); std::unique_ptr<GlobalValueSummary> Summary = std::move(List.front()); - // Add the module path string ref for this module if we haven't already - // saved a reference to it. - if (ModPath.empty()) { - auto Path = Summary->modulePath(); - ModPath = addModulePath(Path, NextModuleId, Other->getModuleHash(Path)) - ->first(); - } else - assert(ModPath == Summary->modulePath() && - "Each module in the combined map should have a unique ID"); - // Note the module path string ref was copied above and is still owned by // the original per-module index. Reset it to the new module path // string reference owned by the combined index. diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index b2d42f4d2a6..94a4abfb896 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/lib/LTO/LTO.cpp @@ -541,13 +541,15 @@ public: ImportList, DefinedGlobals, ModuleMap); }; - if (!Cache) + auto ModuleID = MBRef.getBufferIdentifier(); + if (!Cache || !CombinedIndex.modulePaths().count(ModuleID)) + // Cache disabled or no entry for this module in the combined index return RunThinBackend(AddStream); SmallString<40> Key; // The module may be cached, this helps handling it. - computeCacheKey(Key, CombinedIndex, MBRef.getBufferIdentifier(), - ImportList, ExportList, ResolvedODR, DefinedGlobals); + computeCacheKey(Key, CombinedIndex, ModuleID, ImportList, ExportList, + ResolvedODR, DefinedGlobals); if (AddStreamFn CacheAddStream = Cache(Task, Key)) return RunThinBackend(CacheAddStream); diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp index f4232dc2f89..8afe13d8e16 100644 --- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp +++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp @@ -234,6 +234,10 @@ public: if (CachePath.empty()) return; + if (!Index.modulePaths().count(ModuleID)) + // The module does not have an entry, it can't have a hash at all + return; + // Compute the unique hash for this entry // This is based on the current compiler version, the module itself, the // export list, the hash for every single module in the import list, the |