llvm.org GIT mirror llvm / b818787
[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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@343687 91177308-0d34-0410-b5e6-96231b3b80d8 James Henderson 1 year, 9 months ago
2 changed file(s) with 11 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
112112 ; RUN: %python -c "with open(r'%t.cache/llvmcache-foo-77k', 'w') as file: file.truncate(78848)"
113113 ; RUN: touch -t 198002031200 %t.cache/llvmcache-foo-77k
114114 ; RUN: %python -c "with open(r'%t.cache/llvmcache-foo-8', 'w') as file: file.truncate(8)"
115 ; RUN: touch -t 198002041200 %t.cache/llvmcache-foo-8
115116 ; RUN: %python -c "with open(r'%t.cache/llvmcache-foo-76', 'w') as file: file.truncate(76)"
116 ; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache --thinlto-cache-max-size-bytes 78847
117 ; RUN: touch -t 198002051200 %t.cache/llvmcache-foo-76
118 ; 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
117119 ; RUN: ls %t.cache/llvmcache-foo-8
118120 ; RUN: ls %t.cache/llvmcache-foo-76
119121 ; RUN: not ls %t.cache/llvmcache-foo-16
145147 ; RUN: %python -c "print(' ' * 7)" > %t.cache/llvmcache-foo-7
146148 ; RUN: touch -t 198002031200 %t.cache/llvmcache-foo-7
147149 ; RUN: %python -c "print(' ' * 75)" > %t.cache/llvmcache-foo-75
150 ; RUN: touch -t 198002041200 %t.cache/llvmcache-foo-75
148151 ; RUN: %python -c "print(' ' * 76)" > %t.cache/llvmcache-foo-76
149 ; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache --thinlto-cache-max-size-files 4
152 ; RUN: touch -t 198002051200 %t.cache/llvmcache-foo-76
153 ; 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
150154 ; RUN: ls %t.cache/llvmcache-foo-75
151155 ; RUN: ls %t.cache/llvmcache-foo-76
152156 ; RUN: not ls %t.cache/llvmcache-foo-15
165165 ThinLTOCacheMaxSizeFiles("thinlto-cache-max-size-files", cl::init(1000000),
166166 cl::desc("Set ThinLTO cache pruning directory maximum number of files."));
167167
168 static cl::opt
169 ThinLTOCacheEntryExpiration("thinlto-cache-entry-expiration", cl::init(604800) /* 1w */,
170 cl::desc("Set ThinLTO cache entry expiration time."));
171
168172 static cl::opt ThinLTOSaveTempsPrefix(
169173 "thinlto-save-temps",
170174 cl::desc("Save ThinLTO temp files using filenames created by adding "
480484 ThinGenerator.setTargetOptions(Options);
481485 ThinGenerator.setCacheDir(ThinLTOCacheDir);
482486 ThinGenerator.setCachePruningInterval(ThinLTOCachePruningInterval);
487 ThinGenerator.setCacheEntryExpiration(ThinLTOCacheEntryExpiration);
483488 ThinGenerator.setCacheMaxSizeFiles(ThinLTOCacheMaxSizeFiles);
484489 ThinGenerator.setCacheMaxSizeBytes(ThinLTOCacheMaxSizeBytes);
485490 ThinGenerator.setFreestanding(EnableFreestanding);