1c931ff72SLeonard Grey; REQUIRES: x86 2c931ff72SLeonard Grey; NetBSD: noatime mounts currently inhibit 'touch' from updating atime 3c931ff72SLeonard Grey; UNSUPPORTED: system-netbsd 4c931ff72SLeonard Grey 5c931ff72SLeonard Grey; RUN: rm -rf %t; split-file %s %t 6c931ff72SLeonard Grey; RUN: opt -module-hash -module-summary %t/foo.ll -o %t/foo.o 7c931ff72SLeonard Grey; RUN: opt -module-hash -module-summary %t/bar.ll -o %t/bar.o 8c931ff72SLeonard Grey 9c931ff72SLeonard Grey; RUN: rm -Rf %t/cache && mkdir %t/cache 10c931ff72SLeonard Grey;; Create two files that would be removed by cache pruning due to age. 11c931ff72SLeonard Grey;; We should only remove files matching the pattern "llvmcache-*". 12c931ff72SLeonard Grey; RUN: touch -t 197001011200 %t/cache/llvmcache-baz %t/cache/baz 13c931ff72SLeonard Grey; RUN: %lld -cache_path_lto %t/cache \ 14c931ff72SLeonard Grey; RUN: --thinlto-cache-policy=prune_after=1h:prune_interval=0s \ 15c931ff72SLeonard Grey; RUN: -o %t/test %t/foo.o %t/bar.o 16c931ff72SLeonard Grey 17c931ff72SLeonard Grey;; Two cached objects, plus a timestamp file and "baz", minus the file we removed. 18c931ff72SLeonard Grey; RUN: ls %t/cache | count 4 19c931ff72SLeonard Grey 20c931ff72SLeonard Grey;; Same thing, but with `-prune_after_lto` 21c931ff72SLeonard Grey; RUN: touch -t 197001011200 %t/cache/llvmcache-baz 22c931ff72SLeonard Grey; RUN: %lld -cache_path_lto %t/cache -prune_after_lto 3600 -prune_interval_lto 0 \ 23c931ff72SLeonard Grey; RUN: -o %t/test %t/foo.o %t/bar.o 24c931ff72SLeonard Grey; RUN: ls %t/cache | count 4 25c931ff72SLeonard Grey 26c931ff72SLeonard Grey;; Create a file of size 64KB. 27c931ff72SLeonard Grey; RUN: %python -c "print(' ' * 65536)" > %t/cache/llvmcache-baz 28c931ff72SLeonard Grey 29c931ff72SLeonard Grey;; This should leave the file in place. 30c931ff72SLeonard Grey; RUN: %lld -cache_path_lto %t/cache \ 31c931ff72SLeonard Grey; RUN: --thinlto-cache-policy=cache_size_bytes=128k:prune_interval=0s \ 32c931ff72SLeonard Grey; RUN: -o %t/test %t/foo.o %t/bar.o 33c931ff72SLeonard Grey; RUN: ls %t/cache | count 5 34c931ff72SLeonard Grey 35c931ff72SLeonard Grey;; Increase the age of llvmcache-baz, which will give it the oldest time stamp 36c931ff72SLeonard Grey;; so that it is processed and removed first. 37c931ff72SLeonard Grey; RUN: %python -c 'import os,sys,time; t=time.time()-120; os.utime(sys.argv[1],(t,t))' \ 38c931ff72SLeonard Grey; RUN: %t/cache/llvmcache-baz 39c931ff72SLeonard Grey 40c931ff72SLeonard Grey;; This should remove it. 41c931ff72SLeonard Grey; RUN: %lld -cache_path_lto %t/cache \ 42c931ff72SLeonard Grey; RUN: --thinlto-cache-policy=cache_size_bytes=32k:prune_interval=0s \ 43c931ff72SLeonard Grey; RUN: -o %t/test %t/foo.o %t/bar.o 44c931ff72SLeonard Grey; RUN: ls %t/cache | count 4 45c931ff72SLeonard Grey 46c931ff72SLeonard Grey;; Delete everything except for the timestamp, "baz" and one cache file. 47c931ff72SLeonard Grey; RUN: %lld -cache_path_lto %t/cache \ 48c931ff72SLeonard Grey; RUN: --thinlto-cache-policy=prune_after=0s:cache_size=0%:cache_size_files=1:prune_interval=0s \ 49c931ff72SLeonard Grey; RUN: -o %t/test %t/foo.o %t/bar.o 50c931ff72SLeonard Grey; RUN: ls %t/cache | count 3 51c931ff72SLeonard Grey 52c931ff72SLeonard Grey;; Check that we remove the least recently used file first. 53c931ff72SLeonard Grey; RUN: rm -fr %t/cache 54c931ff72SLeonard Grey; RUN: mkdir %t/cache 55c931ff72SLeonard Grey; RUN: echo xyz > %t/cache/llvmcache-old 56c931ff72SLeonard Grey; RUN: touch -t 198002011200 %t/cache/llvmcache-old 57c931ff72SLeonard Grey; RUN: echo xyz > %t/cache/llvmcache-newer 58c931ff72SLeonard Grey; RUN: touch -t 198002021200 %t/cache/llvmcache-newer 59c931ff72SLeonard Grey; RUN: %lld -cache_path_lto %t/cache \ 60c931ff72SLeonard Grey; RUN: --thinlto-cache-policy=prune_after=0s:cache_size=0%:cache_size_files=3:prune_interval=0s \ 61c931ff72SLeonard Grey; RUN: -o %t/test %t/foo.o %t/bar.o 62c931ff72SLeonard Grey; RUN: ls %t/cache | FileCheck %s 63c931ff72SLeonard Grey 64c931ff72SLeonard Grey;; Check that `-max_relative_cache_size_lto` is a legal argument. 65c931ff72SLeonard Grey; RUN: %lld -cache_path_lto %t/cache -max_relative_cache_size_lto 10 \ 66c931ff72SLeonard Grey; RUN: -o %t/test %t/foo.o %t/bar.o 67c931ff72SLeonard Grey 68c931ff72SLeonard Grey; CHECK-NOT: llvmcache-old 69c931ff72SLeonard Grey; CHECK: llvmcache-newer 70c931ff72SLeonard Grey; CHECK-NOT: llvmcache-old 71c931ff72SLeonard Grey 72*67d311a5SNico Weber;; Check that mllvm options participate in the cache key 73*67d311a5SNico Weber; RUN: rm -rf %t/cache && mkdir %t/cache 74*67d311a5SNico Weber; RUN: %lld -cache_path_lto %t/cache -o %t/test %t/foo.o %t/bar.o 75*67d311a5SNico Weber; RUN: ls %t/cache | count 3 76*67d311a5SNico Weber; RUN: %lld -cache_path_lto %t/cache -o %t/test %t/foo.o %t/bar.o -mllvm -enable-ml-inliner=default 77*67d311a5SNico Weber; RUN: ls %t/cache | count 5 78*67d311a5SNico Weber 79*67d311a5SNico Weber;; Adding another option resuls in 2 more cache entries 80*67d311a5SNico Weber; RUN: rm -rf %t/cache && mkdir %t/cache 81*67d311a5SNico Weber; RUN: %lld -cache_path_lto %t/cache -o %t/test %t/foo.o %t/bar.o 82*67d311a5SNico Weber; RUN: ls %t/cache | count 3 83*67d311a5SNico Weber; RUN: %lld -cache_path_lto %t/cache -o %t/test %t/foo.o %t/bar.o -mllvm -enable-ml-inliner=default 84*67d311a5SNico Weber; RUN: ls %t/cache | count 5 85*67d311a5SNico Weber; RUN: %lld -cache_path_lto %t/cache -o %t/test %t/foo.o %t/bar.o -mllvm -enable-ml-inliner=default -mllvm -max-devirt-iterations=1 86*67d311a5SNico Weber; RUN: ls %t/cache | count 7 87*67d311a5SNico Weber 88*67d311a5SNico Weber;; Changing order may matter - e.g. if overriding -mllvm options - so we get 2 more entries 89*67d311a5SNico Weber; RUN: %lld -cache_path_lto %t/cache -o %t/test %t/foo.o %t/bar.o -mllvm -max-devirt-iterations=1 -mllvm -enable-ml-inliner=default 90*67d311a5SNico Weber; RUN: ls %t/cache | count 9 91*67d311a5SNico Weber 92*67d311a5SNico Weber;; Going back to a pre-cached order doesn't create more entries. 93*67d311a5SNico Weber; RUN: %lld -cache_path_lto %t/cache -o %t/test %t/foo.o %t/bar.o -mllvm -enable-ml-inliner=default -mllvm -max-devirt-iterations=1 94*67d311a5SNico Weber; RUN: ls %t/cache | count 9 95*67d311a5SNico Weber 96*67d311a5SNico Weber;; Different flag values matter 97*67d311a5SNico Weber; RUN: rm -rf %t/cache && mkdir %t/cache 98*67d311a5SNico Weber; RUN: %lld -cache_path_lto %t/cache -o %t/test %t/foo.o %t/bar.o -mllvm -enable-ml-inliner=default -mllvm -max-devirt-iterations=2 99*67d311a5SNico Weber; RUN: ls %t/cache | count 3 100*67d311a5SNico Weber; RUN: %lld -cache_path_lto %t/cache -o %t/test %t/foo.o %t/bar.o -mllvm -enable-ml-inliner=default -mllvm -max-devirt-iterations=1 101*67d311a5SNico Weber; RUN: ls %t/cache | count 5 102*67d311a5SNico Weber 103*67d311a5SNico Weber;; Same flag value passed to different flags matters, and switching the order 104*67d311a5SNico Weber;; of the two flags matters. 105*67d311a5SNico Weber; RUN: rm -rf %t/cache && mkdir %t/cache 106*67d311a5SNico Weber; RUN: %lld -cache_path_lto %t/cache -o %t/test %t/foo.o %t/bar.o -mllvm -enable-ml-inliner=default 107*67d311a5SNico Weber; RUN: ls %t/cache | count 3 108*67d311a5SNico Weber; RUN: %lld -cache_path_lto %t/cache -o %t/test %t/foo.o %t/bar.o -mllvm -emit-dwarf-unwind=default 109*67d311a5SNico Weber; RUN: ls %t/cache | count 5 110*67d311a5SNico Weber; RUN: %lld -cache_path_lto %t/cache -o %t/test %t/foo.o %t/bar.o -mllvm -enable-ml-inliner=default 111*67d311a5SNico Weber; RUN: ls %t/cache | count 5 112*67d311a5SNico Weber; RUN: %lld -cache_path_lto %t/cache -o %t/test %t/foo.o %t/bar.o -mllvm -enable-ml-inliner=default -mllvm -emit-dwarf-unwind=default 113*67d311a5SNico Weber; RUN: ls %t/cache | count 7 114*67d311a5SNico Weber; RUN: %lld -cache_path_lto %t/cache -o %t/test %t/foo.o %t/bar.o -mllvm -emit-dwarf-unwind=default -mllvm -enable-ml-inliner=default 115*67d311a5SNico Weber; RUN: ls %t/cache | count 9 116*67d311a5SNico Weber 117c931ff72SLeonard Grey;--- foo.ll 118c931ff72SLeonard Grey 119c931ff72SLeonard Greytarget triple = "x86_64-apple-macosx10.15.0" 120c931ff72SLeonard Greytarget datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 121c931ff72SLeonard Grey 122c931ff72SLeonard Greydefine void @globalfunc() #0 { 123c931ff72SLeonard Greyentry: 124c931ff72SLeonard Grey ret void 125c931ff72SLeonard Grey} 126c931ff72SLeonard Grey 127c931ff72SLeonard Grey 128c931ff72SLeonard Grey;--- bar.ll 129c931ff72SLeonard Grey 130c931ff72SLeonard Greytarget triple = "x86_64-apple-macosx10.15.0" 131c931ff72SLeonard Greytarget datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 132c931ff72SLeonard Grey 133c931ff72SLeonard Greydefine i32 @main() { 134c931ff72SLeonard Greyentry: 135c931ff72SLeonard Grey call void (...) @globalfunc() 136c931ff72SLeonard Grey ret i32 0 137c931ff72SLeonard Grey} 138c931ff72SLeonard Grey 139c931ff72SLeonard Greydeclare void @globalfunc(...) 140