diff options
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/LTO/LTO.cpp | 8 | ||||
| -rw-r--r-- | llvm/lib/LTO/ThinLTOCodeGenerator.cpp | 9 |
2 files changed, 13 insertions, 4 deletions
diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index 94a4abfb896..8d23f53eae6 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/lib/LTO/LTO.cpp @@ -542,8 +542,12 @@ public: }; auto ModuleID = MBRef.getBufferIdentifier(); - if (!Cache || !CombinedIndex.modulePaths().count(ModuleID)) - // Cache disabled or no entry for this module in the combined index + + if (!Cache || !CombinedIndex.modulePaths().count(ModuleID) || + all_of(CombinedIndex.getModuleHash(ModuleID), + [](uint32_t V) { return V == 0; })) + // Cache disabled or no entry for this module in the combined index or + // no module hash. return RunThinBackend(AddStream); SmallString<40> Key; diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp index 8afe13d8e16..10af9870ccb 100644 --- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp +++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp @@ -243,6 +243,13 @@ public: // export list, the hash for every single module in the import list, the // list of ResolvedODR for the module, and the list of preserved symbols. + // Include the hash for the current module + auto ModHash = Index.getModuleHash(ModuleID); + + if (all_of(ModHash, [](uint32_t V) { return V == 0; })) + // No hash entry, no caching! + return; + SHA1 Hasher; // Start with the compiler revision @@ -251,8 +258,6 @@ public: Hasher.update(LLVM_REVISION); #endif - // Include the hash for the current module - auto ModHash = Index.getModuleHash(ModuleID); Hasher.update(ArrayRef<uint8_t>((uint8_t *)&ModHash[0], sizeof(ModHash))); for (auto F : ExportList) // The export list can impact the internalization, be conservative here |

