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