140 lines · plain
1; REQUIRES: x862; NetBSD: noatime mounts currently inhibit 'touch' from updating atime3; UNSUPPORTED: system-netbsd4 5; RUN: rm -rf %t; split-file %s %t6; RUN: opt -module-hash -module-summary %t/foo.ll -o %t/foo.o7; RUN: opt -module-hash -module-summary %t/bar.ll -o %t/bar.o8 9; RUN: rm -Rf %t/cache && mkdir %t/cache10;; 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/baz13; 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.o16 17;; Two cached objects, plus a timestamp file and "baz", minus the file we removed.18; RUN: ls %t/cache | count 419 20;; Same thing, but with `-prune_after_lto`21; RUN: touch -t 197001011200 %t/cache/llvmcache-baz22; 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.o24; RUN: ls %t/cache | count 425 26;; Create a file of size 64KB.27; RUN: %python -c "print(' ' * 65536)" > %t/cache/llvmcache-baz28 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.o33; RUN: ls %t/cache | count 534 35;; Increase the age of llvmcache-baz, which will give it the oldest time stamp36;; 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-baz39 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.o44; RUN: ls %t/cache | count 445 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.o50; RUN: ls %t/cache | count 351 52;; Check that we remove the least recently used file first.53; RUN: rm -fr %t/cache54; RUN: mkdir %t/cache55; RUN: echo xyz > %t/cache/llvmcache-old56; RUN: touch -t 198002011200 %t/cache/llvmcache-old57; RUN: echo xyz > %t/cache/llvmcache-newer58; RUN: touch -t 198002021200 %t/cache/llvmcache-newer59; 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.o62; RUN: ls %t/cache | FileCheck %s63 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.o67 68; CHECK-NOT: llvmcache-old69; CHECK: llvmcache-newer70; CHECK-NOT: llvmcache-old71 72;; Check that mllvm options participate in the cache key73; RUN: rm -rf %t/cache && mkdir %t/cache74; RUN: %lld -cache_path_lto %t/cache -o %t/test %t/foo.o %t/bar.o75; RUN: ls %t/cache | count 376; RUN: %lld -cache_path_lto %t/cache -o %t/test %t/foo.o %t/bar.o -mllvm -enable-ml-inliner=default77; RUN: ls %t/cache | count 578 79;; Adding another option resuls in 2 more cache entries80; RUN: rm -rf %t/cache && mkdir %t/cache81; RUN: %lld -cache_path_lto %t/cache -o %t/test %t/foo.o %t/bar.o82; RUN: ls %t/cache | count 383; RUN: %lld -cache_path_lto %t/cache -o %t/test %t/foo.o %t/bar.o -mllvm -enable-ml-inliner=default84; RUN: ls %t/cache | count 585; 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=186; RUN: ls %t/cache | count 787 88;; Changing order may matter - e.g. if overriding -mllvm options - so we get 2 more entries89; 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=default90; RUN: ls %t/cache | count 991 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=194; RUN: ls %t/cache | count 995 96;; Different flag values matter97; RUN: rm -rf %t/cache && mkdir %t/cache98; 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=299; RUN: ls %t/cache | count 3100; 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=1101; RUN: ls %t/cache | count 5102 103;; Same flag value passed to different flags matters, and switching the order104;; of the two flags matters.105; RUN: rm -rf %t/cache && mkdir %t/cache106; RUN: %lld -cache_path_lto %t/cache -o %t/test %t/foo.o %t/bar.o -mllvm -enable-ml-inliner=default107; RUN: ls %t/cache | count 3108; RUN: %lld -cache_path_lto %t/cache -o %t/test %t/foo.o %t/bar.o -mllvm -emit-dwarf-unwind=default109; RUN: ls %t/cache | count 5110; RUN: %lld -cache_path_lto %t/cache -o %t/test %t/foo.o %t/bar.o -mllvm -enable-ml-inliner=default111; RUN: ls %t/cache | count 5112; 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=default113; RUN: ls %t/cache | count 7114; 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=default115; RUN: ls %t/cache | count 9116 117;--- foo.ll118 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 void125}126 127 128;--- bar.ll129 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 0137}138 139declare void @globalfunc(...)140