summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorMehdi Amini <mehdi.amini@apple.com>2016-10-08 04:44:23 +0000
committerMehdi Amini <mehdi.amini@apple.com>2016-10-08 04:44:23 +0000
commitf82bda0a7ac91c18051f346b719c7cf6faadbc00 (patch)
tree6520f8f922f1812669349d4042f04035206af71d /llvm/lib
parent00fa1409ec8d8d6db8597fbe73eac65094e8b425 (diff)
downloadbcm5719-llvm-f82bda0a7ac91c18051f346b719c7cf6faadbc00.tar.gz
bcm5719-llvm-f82bda0a7ac91c18051f346b719c7cf6faadbc00.zip
ThinLTO: don't perform incremental LTO on module without a hash
Clang always emit a hash for ThinLTO, but as other frontend are starting to use ThinLTO, this could be a serious bug. Differential Revision: https://reviews.llvm.org/D25379 llvm-svn: 283655
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/LTO/LTO.cpp8
-rw-r--r--llvm/lib/LTO/ThinLTOCodeGenerator.cpp9
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
OpenPOWER on IntegriCloud