113 lines · plain
1; REQUIRES: x862; NetBSD: noatime mounts currently inhibit 'touch' from updating atime3; UNSUPPORTED: system-netbsd4 5; RUN: rm -rf %t && mkdir %t && cd %t6; RUN: opt -module-hash -module-summary %s -o a.bc7; RUN: opt -module-hash -module-summary %p/Inputs/cache.ll -o b.bc8 9; RUN: mkdir 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 cache/llvmcache-foo cache/foo13; RUN: ld.lld --thinlto-cache-dir=cache --thinlto-cache-policy prune_after=1h:prune_interval=0s -o out b.bc a.bc14 15; Two cached objects, plus a timestamp file and "foo", minus the file we removed.16; RUN: ls cache | count 417 18; Create a file of size 64KB.19; RUN: %python -c "print(' ' * 65536)" > cache/llvmcache-foo20 21; This should leave the file in place.22; RUN: ld.lld --thinlto-cache-dir=cache --thinlto-cache-policy cache_size_bytes=128k:prune_interval=0s -o out b.bc a.bc23; RUN: ls cache | count 524 25; Increase the age of llvmcache-foo, which will give it the oldest time stamp26; so that it is processed and removed first.27; RUN: %python -c 'import os,sys,time; t=time.time()-120; os.utime(sys.argv[1],(t,t))' cache/llvmcache-foo28 29; This should remove it.30; RUN: ld.lld --thinlto-cache-dir=cache --thinlto-cache-policy cache_size_bytes=32k:prune_interval=0s -o out b.bc a.bc31; RUN: ls cache | count 432 33; Setting max number of files to 0 should disable the limit, not delete everything.34; RUN: ld.lld --thinlto-cache-dir=cache --thinlto-cache-policy prune_after=0s:cache_size=0%:cache_size_files=0:prune_interval=0s -o out b.bc a.bc35; RUN: ls cache | count 436 37; Delete everything except for the timestamp, "foo" and one cache file.38; RUN: ld.lld --thinlto-cache-dir=cache --thinlto-cache-policy prune_after=0s:cache_size=0%:cache_size_files=1:prune_interval=0s -o out b.bc a.bc39; RUN: ls cache | count 340 41; Check that we remove the least recently used file first.42; RUN: rm -fr cache && mkdir cache43; RUN: echo xyz > cache/llvmcache-old44; RUN: touch -t 198002011200 cache/llvmcache-old45; RUN: echo xyz > cache/llvmcache-newer46; RUN: touch -t 198002021200 cache/llvmcache-newer47; RUN: ld.lld --thinlto-cache-dir=cache --thinlto-cache-policy prune_after=0s:cache_size=0%:cache_size_files=3:prune_interval=0s -o out b.bc a.bc48; RUN: ls cache | FileCheck %s49 50; CHECK-NOT: llvmcache-old51; CHECK: llvmcache-newer52; CHECK-NOT: llvmcache-old53 54; RUN: rm -fr cache && mkdir cache55; RUN: ld.lld --thinlto-cache-dir=cache --save-temps -o out b.bc a.bc -M | FileCheck %s --check-prefix=MAP56; RUN: ls out.lto.a.o a.bc.0.preopt.bc b.bc.0.preopt.bc57 58; MAP: out.lto.b.o:(.text)59; MAP: out.lto.a.o:(.text)60 61;; Check that mllvm options participate in the cache key62; RUN: rm -rf cache && mkdir cache63; RUN: ld.lld --thinlto-cache-dir=cache -o out b.bc a.bc64; RUN: ls cache | count 365; RUN: ld.lld --thinlto-cache-dir=cache -o out b.bc a.bc -mllvm -enable-ml-inliner=default66; RUN: ls cache | count 567 68;; Adding another option resuls in 2 more cache entries69; RUN: rm -rf cache && mkdir cache70; RUN: ld.lld --thinlto-cache-dir=cache -o out b.bc a.bc71; RUN: ls cache | count 372; RUN: ld.lld --thinlto-cache-dir=cache -o out b.bc a.bc -mllvm -enable-ml-inliner=default73; RUN: ls cache | count 574; RUN: ld.lld --thinlto-cache-dir=cache -o out b.bc a.bc -mllvm -enable-ml-inliner=default -mllvm -max-devirt-iterations=175; RUN: ls cache | count 776 77;; Changing order may matter - e.g. if overriding -mllvm options - so we get 2 more entries78; RUN: ld.lld --thinlto-cache-dir=cache -o out b.bc a.bc -mllvm -max-devirt-iterations=1 -mllvm -enable-ml-inliner=default79; RUN: ls cache | count 980 81;; Going back to a pre-cached order doesn't create more entries.82; RUN: ld.lld --thinlto-cache-dir=cache -o out b.bc a.bc -mllvm -enable-ml-inliner=default -mllvm -max-devirt-iterations=183; RUN: ls cache | count 984 85;; Different flag values matter86; RUN: rm -rf cache && mkdir cache87; RUN: ld.lld --thinlto-cache-dir=cache -o out b.bc a.bc -mllvm -enable-ml-inliner=default -mllvm -max-devirt-iterations=288; RUN: ls cache | count 389; RUN: ld.lld --thinlto-cache-dir=cache -o out b.bc a.bc -mllvm -enable-ml-inliner=default -mllvm -max-devirt-iterations=190; RUN: ls cache | count 591 92;; Same flag value passed to different flags matters, and switching the order93;; of the two flags matters.94; RUN: rm -rf cache && mkdir cache95; RUN: ld.lld --thinlto-cache-dir=cache -o out b.bc a.bc -mllvm -enable-ml-inliner=default96; RUN: ls cache | count 397; RUN: ld.lld --thinlto-cache-dir=cache -o out b.bc a.bc -mllvm -emit-dwarf-unwind=default98; RUN: ls cache | count 599; RUN: ld.lld --thinlto-cache-dir=cache -o out b.bc a.bc -mllvm -enable-ml-inliner=default100; RUN: ls cache | count 5101; RUN: ld.lld --thinlto-cache-dir=cache -o out b.bc a.bc -mllvm -enable-ml-inliner=default -mllvm -emit-dwarf-unwind=default102; RUN: ls cache | count 7103; RUN: ld.lld --thinlto-cache-dir=cache -o out b.bc a.bc -mllvm -emit-dwarf-unwind=default -mllvm -enable-ml-inliner=default104; RUN: ls cache | count 9105 106target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"107target triple = "x86_64-unknown-linux-gnu"108 109define void @globalfunc() #0 {110entry:111 ret void112}113