[PATCH] D25379: ThinLTO: don't perform incremental LTO on module without a hash
Mehdi AMINI via llvm-commits
llvm-commits at lists.llvm.org
Sat Oct 8 07:18:24 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL283655: ThinLTO: don't perform incremental LTO on module without a hash (authored by mehdi_amini).
Changed prior to commit:
https://reviews.llvm.org/D25379?vs=73978&id=74032#toc
Repository:
rL LLVM
https://reviews.llvm.org/D25379
Files:
llvm/trunk/lib/LTO/LTO.cpp
llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp
llvm/trunk/test/ThinLTO/X86/cache.ll
llvm/trunk/test/ThinLTO/X86/empty_module_with_cache.ll
Index: llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp
===================================================================
--- llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp
+++ llvm/trunk/lib/LTO/ThinLTOCodeGenerator.cpp
@@ -243,16 +243,21 @@
// 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
Hasher.update(LLVM_VERSION_STRING);
#ifdef HAVE_LLVM_REVISION
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
Index: llvm/trunk/lib/LTO/LTO.cpp
===================================================================
--- llvm/trunk/lib/LTO/LTO.cpp
+++ llvm/trunk/lib/LTO/LTO.cpp
@@ -542,8 +542,12 @@
};
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;
Index: llvm/trunk/test/ThinLTO/X86/empty_module_with_cache.ll
===================================================================
--- llvm/trunk/test/ThinLTO/X86/empty_module_with_cache.ll
+++ llvm/trunk/test/ThinLTO/X86/empty_module_with_cache.ll
@@ -22,13 +22,13 @@
; RUN: rm -Rf %t.cache && mkdir %t.cache
; RUN: llvm-lto -thinlto-action=run %t2.bc %t.bc -exported-symbol=main -thinlto-cache-dir %t.cache
; RUN: ls %t.cache/llvmcache.timestamp
-; RUN: ls %t.cache | count 2
+; RUN: ls %t.cache | count 1
; Verify that caching is disabled for module without hash, with llvm-lto2
; RUN: rm -Rf %t.cache && mkdir %t.cache
; RUN: llvm-lto2 -o %t.o %t2.bc %t.bc -cache-dir %t.cache \
; RUN: -r=%t2.bc,_main,plx
-; RUN: ls %t.cache | count 1
+; RUN: ls %t.cache | count 0
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
Index: llvm/trunk/test/ThinLTO/X86/cache.ll
===================================================================
--- llvm/trunk/test/ThinLTO/X86/cache.ll
+++ llvm/trunk/test/ThinLTO/X86/cache.ll
@@ -1,6 +1,28 @@
+; Verify first that *without* hash, we don't use the cache.
+
; RUN: opt -module-summary %s -o %t.bc
; RUN: opt -module-summary %p/Inputs/cache.ll -o %t2.bc
+; Verify that enabling caching is ignoring module without hash
+; RUN: rm -Rf %t.cache && mkdir %t.cache
+; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache
+; RUN: ls %t.cache/llvmcache.timestamp
+; RUN: ls %t.cache | count 1
+
+; Verify that enabling caching is ignoring module without hash with llvm-lto2
+; RUN: rm -Rf %t.cache && mkdir %t.cache
+; RUN: llvm-lto2 -o %t.o %t2.bc %t.bc -cache-dir %t.cache \
+; RUN: -r=%t2.bc,_main,plx \
+; RUN: -r=%t2.bc,_globalfunc,lx \
+; RUN: -r=%t.bc,_globalfunc,plx
+; RUN: ls %t.cache | count 0
+
+
+; Repeat again, *with* hash this time.
+
+; RUN: opt -module-hash -module-summary %s -o %t.bc
+; RUN: opt -module-hash -module-summary %p/Inputs/cache.ll -o %t2.bc
+
; Verify that enabling caching is working
; RUN: rm -Rf %t.cache && mkdir %t.cache
; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D25379.74032.patch
Type: text/x-patch
Size: 3990 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20161008/7bee94bf/attachment.bin>
More information about the llvm-commits
mailing list