1; NetBSD: noatime mounts currently inhibit 'touch -a' updates 2; UNSUPPORTED: system-netbsd 3 4; The .noindex suffix for output dir is to prevent Spotlight on macOS from 5; indexing it. 6 7; Verify first that *without* hash, we don't use the cache. 8; RUN: opt -module-summary %s -o %t.bc 9; RUN: opt -module-summary %p/Inputs/cache.ll -o %t2.bc 10 11; Verify that enabling caching is ignoring module without hash 12; RUN: rm -Rf %t.cache.noindex && mkdir %t.cache.noindex 13; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache.noindex 14; RUN: ls %t.cache.noindex/llvmcache.timestamp 15; RUN: ls %t.cache.noindex | count 1 16 17; Verify that enabling caching is ignoring module without hash with llvm-lto2 18; RUN: rm -Rf %t.cache.noindex 19; 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,plx 23; RUN: not ls %t.cache.noindex 24 25 26; Repeat again, *with* hash this time. 27 28; RUN: opt -module-hash -module-summary %s -o %t.bc 29; RUN: opt -module-hash -module-summary %p/Inputs/cache.ll -o %t2.bc 30 31; Verify that enabling caching is working, and that the pruner only removes 32; files matching the pattern "llvmcache-*". 33; RUN: rm -Rf %t.cache.noindex && mkdir %t.cache.noindex 34; RUN: touch -t 197001011200 %t.cache.noindex/llvmcache-foo %t.cache.noindex/foo 35; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache.noindex 36; RUN: ls %t.cache.noindex | count 4 37; RUN: ls %t.cache.noindex/llvmcache.timestamp 38; RUN: ls %t.cache.noindex/foo 39; RUN: not ls %t.cache.noindex/llvmcache-foo 40; RUN: ls %t.cache.noindex/llvmcache-* | count 2 41 42; Verify that enabling caching is working with llvm-lto2 43; RUN: rm -Rf %t.cache.noindex 44; 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,plx 48; RUN: ls %t.cache.noindex | count 2 49; RUN: ls %t.cache.noindex/llvmcache-* | count 2 50 51; Verify that caches with a timestamp older than the pruning interval 52; will be pruned 53; RUN: rm -Rf %t.cache.noindex && mkdir %t.cache.noindex 54; RUN: touch -t 197001011200 %t.cache.noindex/llvmcache-foo 55; RUN: touch -t 197001011200 %t.cache.noindex/llvmcache.timestamp 56; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache.noindex 57; RUN: not ls %t.cache.noindex/llvmcache-foo 58 59; Verify that specifying a negative number for the pruning interval 60; effectively disables the pruning 61; RUN: rm -Rf %t.cache.noindex && mkdir %t.cache.noindex 62; RUN: touch -t 197001011200 %t.cache.noindex/llvmcache-foo 63; RUN: touch -t 197001011200 %t.cache.noindex/llvmcache.timestamp 64; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache.noindex --thinlto-cache-pruning-interval -1 65; RUN: ls %t.cache.noindex/llvmcache-foo 66 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.noindex 72; RUN: touch -t 197001011200 %t.cache.noindex/llvmcache-foo 73; RUN: touch %t.cache.noindex/llvmcache.timestamp 74; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache.noindex 75; RUN: ls %t.cache.noindex/llvmcache-foo 76 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.noindex 83; RUN: touch -t 197001011200 %t.cache.noindex/llvmcache-foo 84; RUN: touch %t.cache.noindex/llvmcache.timestamp 85; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache.noindex --thinlto-cache-pruning-interval 0 86; RUN: not ls %t.cache.noindex/llvmcache-foo 87 88; Populate the cache with files with "old" access times, then check llvm-lto updates these file times 89; A negative pruning interval is used to avoid removing cache entries 90; RUN: rm -Rf %t.cache.noindex && mkdir %t.cache.noindex 91; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache.noindex 92; 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 -1 94; RUN: ls -ltu %t.cache.noindex/* | not grep 1970-01-01 95 96; Populate the cache with files with "old" access times, then check llvm-lto2 updates these file times 97; RUN: rm -Rf %t.cache.noindex 98; 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,plx 102; 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,plx 107; RUN: ls -ltu %t.cache.noindex/* | not grep 1970-01-01 108 109; Verify that specifying max size for the cache directory prunes it to this 110; size, removing the oldest files first. 111; RUN: rm -Rf %t.cache.noindex && mkdir %t.cache.noindex 112; 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-100k 116; 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-16 118; 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-77k 120; 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-8 122; 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-76 124; 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 4294967295 125; RUN: ls %t.cache.noindex/llvmcache-foo-8 126; RUN: ls %t.cache.noindex/llvmcache-foo-76 127; RUN: not ls %t.cache.noindex/llvmcache-foo-16 128; RUN: not ls %t.cache.noindex/llvmcache-foo-100k 129; RUN: not ls %t.cache.noindex/llvmcache-foo-77k 130 131; Verify that specifying a max size > 4GB for the cache directory does not 132; prematurely prune, due to an integer overflow. 133; RUN: rm -Rf %t.cache.noindex && mkdir %t.cache.noindex 134; 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 4294967297 136; RUN: ls %t.cache.noindex/llvmcache-foo-10 137 138; Verify that negative numbers aren't accepted for the 139; --thinlto-cache-max-size-bytes switch 140; RUN: rm -Rf %t.cache.noindex && mkdir %t.cache.noindex 141; RUN: not llvm-lto %t.bc --thinlto-cache-max-size-bytes -1 2>&1 | FileCheck %s 142; CHECK: -thinlto-cache-max-size-bytes option: '-1' value invalid 143 144; Verify that specifying max number of files in the cache directory prunes 145; it to this amount, removing the oldest files first. 146; RUN: rm -Rf %t.cache.noindex && mkdir %t.cache.noindex 147; 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-1023 150; RUN: touch -t 198002011200 %t.cache.noindex/llvmcache-foo-1023 151; RUN: %python -c "print(' ' * 15)" > %t.cache.noindex/llvmcache-foo-15 152; RUN: touch -t 198002021200 %t.cache.noindex/llvmcache-foo-15 153; RUN: %python -c "print(' ' * 7)" > %t.cache.noindex/llvmcache-foo-7 154; RUN: touch -t 198002031200 %t.cache.noindex/llvmcache-foo-7 155; RUN: %python -c "print(' ' * 75)" > %t.cache.noindex/llvmcache-foo-75 156; RUN: touch -t 198002041200 %t.cache.noindex/llvmcache-foo-75 157; RUN: %python -c "print(' ' * 76)" > %t.cache.noindex/llvmcache-foo-76 158; RUN: touch -t 198002051200 %t.cache.noindex/llvmcache-foo-76 159; 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 4294967295 160; RUN: ls %t.cache.noindex/llvmcache-foo-75 161; RUN: ls %t.cache.noindex/llvmcache-foo-76 162; RUN: not ls %t.cache.noindex/llvmcache-foo-15 163; RUN: not ls %t.cache.noindex/llvmcache-foo-1024 164; RUN: not ls %t.cache.noindex/llvmcache-foo-7 165 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 void 172} 173