173 lines · plain
1; NetBSD: noatime mounts currently inhibit 'touch -a' updates2; UNSUPPORTED: system-netbsd3 4; The .noindex suffix for output dir is to prevent Spotlight on macOS from5; indexing it.6 7; Verify first that *without* hash, we don't use the cache.8; RUN: opt -module-summary %s -o %t.bc9; RUN: opt -module-summary %p/Inputs/cache.ll -o %t2.bc10 11; Verify that enabling caching is ignoring module without hash12; RUN: rm -Rf %t.cache.noindex && mkdir %t.cache.noindex13; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache.noindex14; RUN: ls %t.cache.noindex/llvmcache.timestamp15; RUN: ls %t.cache.noindex | count 116 17; Verify that enabling caching is ignoring module without hash with llvm-lto218; RUN: rm -Rf %t.cache.noindex19; RUN: llvm-lto2 run -o %t.o %t2.bc %t.bc -cache-dir %t.cache.noindex \20; RUN: -r=%t2.bc,_main,plx \21; RUN: -r=%t2.bc,_globalfunc,lx \22; RUN: -r=%t.bc,_globalfunc,plx23; RUN: not ls %t.cache.noindex24 25 26; Repeat again, *with* hash this time.27 28; RUN: opt -module-hash -module-summary %s -o %t.bc29; RUN: opt -module-hash -module-summary %p/Inputs/cache.ll -o %t2.bc30 31; Verify that enabling caching is working, and that the pruner only removes32; files matching the pattern "llvmcache-*".33; RUN: rm -Rf %t.cache.noindex && mkdir %t.cache.noindex34; RUN: touch -t 197001011200 %t.cache.noindex/llvmcache-foo %t.cache.noindex/foo35; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache.noindex36; RUN: ls %t.cache.noindex | count 437; RUN: ls %t.cache.noindex/llvmcache.timestamp38; RUN: ls %t.cache.noindex/foo39; RUN: not ls %t.cache.noindex/llvmcache-foo40; RUN: ls %t.cache.noindex/llvmcache-* | count 241 42; Verify that enabling caching is working with llvm-lto243; RUN: rm -Rf %t.cache.noindex44; RUN: llvm-lto2 run -o %t.o %t2.bc %t.bc -cache-dir %t.cache.noindex \45; RUN: -r=%t2.bc,_main,plx \46; RUN: -r=%t2.bc,_globalfunc,lx \47; RUN: -r=%t.bc,_globalfunc,plx48; RUN: ls %t.cache.noindex | count 249; RUN: ls %t.cache.noindex/llvmcache-* | count 250 51; Verify that caches with a timestamp older than the pruning interval52; will be pruned53; RUN: rm -Rf %t.cache.noindex && mkdir %t.cache.noindex54; RUN: touch -t 197001011200 %t.cache.noindex/llvmcache-foo55; RUN: touch -t 197001011200 %t.cache.noindex/llvmcache.timestamp56; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache.noindex57; RUN: not ls %t.cache.noindex/llvmcache-foo58 59; Verify that specifying a negative number for the pruning interval60; effectively disables the pruning61; RUN: rm -Rf %t.cache.noindex && mkdir %t.cache.noindex62; RUN: touch -t 197001011200 %t.cache.noindex/llvmcache-foo63; RUN: touch -t 197001011200 %t.cache.noindex/llvmcache.timestamp64; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache.noindex --thinlto-cache-pruning-interval -165; RUN: ls %t.cache.noindex/llvmcache-foo66 67; Verify that the pruner doesn't run and a cache file is not deleted when: 68; default values for pruning interval and cache expiration are used, 69; llvmcache.timestamp is current, 70; cache file is older than default cache expiration value.71; RUN: rm -Rf %t.cache.noindex && mkdir %t.cache.noindex72; RUN: touch -t 197001011200 %t.cache.noindex/llvmcache-foo73; RUN: touch %t.cache.noindex/llvmcache.timestamp74; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache.noindex75; RUN: ls %t.cache.noindex/llvmcache-foo76 77; Verify that the pruner runs and a cache file is deleted when:78; pruning interval has value 0 (i.e. run garbage collector now)79; default value for cache expiration is used,80; llvmcache.timestamp is current,81; cache file is older than default cache expiration value.82; RUN: rm -Rf %t.cache.noindex && mkdir %t.cache.noindex83; RUN: touch -t 197001011200 %t.cache.noindex/llvmcache-foo84; RUN: touch %t.cache.noindex/llvmcache.timestamp85; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache.noindex --thinlto-cache-pruning-interval 086; RUN: not ls %t.cache.noindex/llvmcache-foo87 88; Populate the cache with files with "old" access times, then check llvm-lto updates these file times89; A negative pruning interval is used to avoid removing cache entries90; RUN: rm -Rf %t.cache.noindex && mkdir %t.cache.noindex91; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache.noindex92; RUN: touch -a -t 197001011200 %t.cache.noindex/llvmcache-*93; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache.noindex --thinlto-cache-pruning-interval -194; RUN: ls -ltu %t.cache.noindex/* | not grep 1970-01-0195 96; Populate the cache with files with "old" access times, then check llvm-lto2 updates these file times97; RUN: rm -Rf %t.cache.noindex98; RUN: llvm-lto2 run -o %t.o %t2.bc %t.bc -cache-dir %t.cache.noindex \99; RUN: -r=%t2.bc,_main,plx \100; RUN: -r=%t2.bc,_globalfunc,lx \101; RUN: -r=%t.bc,_globalfunc,plx102; RUN: touch -a -t 197001011200 %t.cache.noindex/llvmcache-*103; RUN: llvm-lto2 run -o %t.o %t2.bc %t.bc -cache-dir %t.cache.noindex \104; RUN: -r=%t2.bc,_main,plx \105; RUN: -r=%t2.bc,_globalfunc,lx \106; RUN: -r=%t.bc,_globalfunc,plx107; RUN: ls -ltu %t.cache.noindex/* | not grep 1970-01-01108 109; Verify that specifying max size for the cache directory prunes it to this110; size, removing the oldest files first.111; RUN: rm -Rf %t.cache.noindex && mkdir %t.cache.noindex112; Create cache files with different sizes.113; Only 8B and 76B files should stay after pruning.114; RUN: %python -c "with open(r'%t.cache.noindex/llvmcache-foo-100k', 'w') as file: file.truncate(102400)"115; RUN: touch -t 198002011200 %t.cache.noindex/llvmcache-foo-100k116; RUN: %python -c "with open(r'%t.cache.noindex/llvmcache-foo-16', 'w') as file: file.truncate(16)"117; RUN: touch -t 198002021200 %t.cache.noindex/llvmcache-foo-16118; RUN: %python -c "with open(r'%t.cache.noindex/llvmcache-foo-77k', 'w') as file: file.truncate(78848)"119; RUN: touch -t 198002031200 %t.cache.noindex/llvmcache-foo-77k120; RUN: %python -c "with open(r'%t.cache.noindex/llvmcache-foo-8', 'w') as file: file.truncate(8)"121; RUN: touch -t 198002041200 %t.cache.noindex/llvmcache-foo-8122; RUN: %python -c "with open(r'%t.cache.noindex/llvmcache-foo-76', 'w') as file: file.truncate(76)"123; RUN: touch -t 198002051200 %t.cache.noindex/llvmcache-foo-76124; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache.noindex --thinlto-cache-max-size-bytes 78847 --thinlto-cache-entry-expiration 4294967295125; RUN: ls %t.cache.noindex/llvmcache-foo-8126; RUN: ls %t.cache.noindex/llvmcache-foo-76127; RUN: not ls %t.cache.noindex/llvmcache-foo-16128; RUN: not ls %t.cache.noindex/llvmcache-foo-100k129; RUN: not ls %t.cache.noindex/llvmcache-foo-77k130 131; Verify that specifying a max size > 4GB for the cache directory does not132; prematurely prune, due to an integer overflow.133; RUN: rm -Rf %t.cache.noindex && mkdir %t.cache.noindex134; RUN: %python -c "with open(r'%t.cache.noindex/llvmcache-foo-10', 'w') as file: file.truncate(10)"135; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache.noindex --thinlto-cache-max-size-bytes 4294967297136; RUN: ls %t.cache.noindex/llvmcache-foo-10137 138; Verify that negative numbers aren't accepted for the139; --thinlto-cache-max-size-bytes switch140; RUN: rm -Rf %t.cache.noindex && mkdir %t.cache.noindex141; RUN: not llvm-lto %t.bc --thinlto-cache-max-size-bytes -1 2>&1 | FileCheck %s142; CHECK: -thinlto-cache-max-size-bytes option: '-1' value invalid143 144; Verify that specifying max number of files in the cache directory prunes145; it to this amount, removing the oldest files first.146; RUN: rm -Rf %t.cache.noindex && mkdir %t.cache.noindex147; Create cache files with different sizes.148; Only 75B and 76B files should stay after pruning.149; RUN: %python -c "print(' ' * 1023)" > %t.cache.noindex/llvmcache-foo-1023150; RUN: touch -t 198002011200 %t.cache.noindex/llvmcache-foo-1023151; RUN: %python -c "print(' ' * 15)" > %t.cache.noindex/llvmcache-foo-15152; RUN: touch -t 198002021200 %t.cache.noindex/llvmcache-foo-15153; RUN: %python -c "print(' ' * 7)" > %t.cache.noindex/llvmcache-foo-7154; RUN: touch -t 198002031200 %t.cache.noindex/llvmcache-foo-7155; RUN: %python -c "print(' ' * 75)" > %t.cache.noindex/llvmcache-foo-75156; RUN: touch -t 198002041200 %t.cache.noindex/llvmcache-foo-75157; RUN: %python -c "print(' ' * 76)" > %t.cache.noindex/llvmcache-foo-76158; RUN: touch -t 198002051200 %t.cache.noindex/llvmcache-foo-76159; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache.noindex --thinlto-cache-max-size-files 4 --thinlto-cache-entry-expiration 4294967295160; RUN: ls %t.cache.noindex/llvmcache-foo-75161; RUN: ls %t.cache.noindex/llvmcache-foo-76162; RUN: not ls %t.cache.noindex/llvmcache-foo-15163; RUN: not ls %t.cache.noindex/llvmcache-foo-1024164; RUN: not ls %t.cache.noindex/llvmcache-foo-7165 166target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"167target triple = "x86_64-apple-macosx10.11.0"168 169define void @globalfunc() #0 {170entry:171 ret void172}173