Skip to content

Commit 99031b7

Browse files
committed
[ThinLTO]Expose cache entry expiration time option in llvm-lto and fix a test
Two cases in a ThinLTO test were passing for the wrong reasons, since rL340374. The tests were supposed to be testing that files were being pruned due to the cache size, but they were in fact being pruned because they were older than the default expiration period of 1 week. This change fixes the tests by explicitly setting the expiration time to the maximum value. This required the option to be exposed in llvm-lto. By assigning all files in the cache a similar time, it is possible to see that the newest files are still being kept, and that we aren't passing for the wrong reason again. In the event that the entry expiration were to expire for them, then the test would start failing, because these files would be removed too. Reviewed by: rnk, inglorion Differential Revision: https://reviews.llvm.org/D51992 llvm-svn: 343687
1 parent fb3a97b commit 99031b7

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

llvm/test/ThinLTO/X86/cache.ll

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,10 @@
113113
; RUN: %python -c "with open(r'%t.cache/llvmcache-foo-77k', 'w') as file: file.truncate(78848)"
114114
; RUN: touch -t 198002031200 %t.cache/llvmcache-foo-77k
115115
; RUN: %python -c "with open(r'%t.cache/llvmcache-foo-8', 'w') as file: file.truncate(8)"
116+
; RUN: touch -t 198002041200 %t.cache/llvmcache-foo-8
116117
; RUN: %python -c "with open(r'%t.cache/llvmcache-foo-76', 'w') as file: file.truncate(76)"
117-
; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache --thinlto-cache-max-size-bytes 78847
118+
; RUN: touch -t 198002051200 %t.cache/llvmcache-foo-76
119+
; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache --thinlto-cache-max-size-bytes 78847 --thinlto-cache-entry-expiration 4294967295
118120
; RUN: ls %t.cache/llvmcache-foo-8
119121
; RUN: ls %t.cache/llvmcache-foo-76
120122
; RUN: not ls %t.cache/llvmcache-foo-16
@@ -146,8 +148,10 @@
146148
; RUN: %python -c "print(' ' * 7)" > %t.cache/llvmcache-foo-7
147149
; RUN: touch -t 198002031200 %t.cache/llvmcache-foo-7
148150
; RUN: %python -c "print(' ' * 75)" > %t.cache/llvmcache-foo-75
151+
; RUN: touch -t 198002041200 %t.cache/llvmcache-foo-75
149152
; RUN: %python -c "print(' ' * 76)" > %t.cache/llvmcache-foo-76
150-
; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache --thinlto-cache-max-size-files 4
153+
; RUN: touch -t 198002051200 %t.cache/llvmcache-foo-76
154+
; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache --thinlto-cache-max-size-files 4 --thinlto-cache-entry-expiration 4294967295
151155
; RUN: ls %t.cache/llvmcache-foo-75
152156
; RUN: ls %t.cache/llvmcache-foo-76
153157
; RUN: not ls %t.cache/llvmcache-foo-15

llvm/tools/llvm-lto/llvm-lto.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ static cl::opt<int>
166166
ThinLTOCacheMaxSizeFiles("thinlto-cache-max-size-files", cl::init(1000000),
167167
cl::desc("Set ThinLTO cache pruning directory maximum number of files."));
168168

169+
static cl::opt<unsigned>
170+
ThinLTOCacheEntryExpiration("thinlto-cache-entry-expiration", cl::init(604800) /* 1w */,
171+
cl::desc("Set ThinLTO cache entry expiration time."));
172+
169173
static cl::opt<std::string> ThinLTOSaveTempsPrefix(
170174
"thinlto-save-temps",
171175
cl::desc("Save ThinLTO temp files using filenames created by adding "
@@ -481,6 +485,7 @@ class ThinLTOProcessing {
481485
ThinGenerator.setTargetOptions(Options);
482486
ThinGenerator.setCacheDir(ThinLTOCacheDir);
483487
ThinGenerator.setCachePruningInterval(ThinLTOCachePruningInterval);
488+
ThinGenerator.setCacheEntryExpiration(ThinLTOCacheEntryExpiration);
484489
ThinGenerator.setCacheMaxSizeFiles(ThinLTOCacheMaxSizeFiles);
485490
ThinGenerator.setCacheMaxSizeBytes(ThinLTOCacheMaxSizeBytes);
486491
ThinGenerator.setFreestanding(EnableFreestanding);

0 commit comments

Comments
 (0)