• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; Verify first that *without* hash, we don't use the cache.
2
3; RUN: opt -module-summary %s -o %t.bc
4; RUN: opt -module-summary %p/Inputs/cache.ll -o %t2.bc
5
6; Verify that enabling caching is ignoring module without hash
7; RUN: rm -Rf %t.cache && mkdir %t.cache
8; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache
9; RUN: ls %t.cache/llvmcache.timestamp
10; RUN: ls %t.cache | count 1
11
12; Verify that enabling caching is ignoring module without hash with llvm-lto2
13; RUN: rm -Rf %t.cache
14; RUN: llvm-lto2 run -o %t.o %t2.bc  %t.bc -cache-dir %t.cache \
15; RUN:  -r=%t2.bc,_main,plx \
16; RUN:  -r=%t2.bc,_globalfunc,lx \
17; RUN:  -r=%t.bc,_globalfunc,plx
18; RUN: ls %t.cache | count 0
19
20
21; Repeat again, *with* hash this time.
22
23; RUN: opt -module-hash -module-summary %s -o %t.bc
24; RUN: opt -module-hash -module-summary %p/Inputs/cache.ll -o %t2.bc
25
26; Verify that enabling caching is working, and that the pruner only removes
27; files matching the pattern "llvmcache-*".
28; RUN: rm -Rf %t.cache && mkdir %t.cache
29; RUN: touch -t 197001011200 %t.cache/llvmcache-foo %t.cache/foo
30; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache
31; RUN: ls %t.cache | count 4
32; RUN: ls %t.cache/llvmcache.timestamp
33; RUN: ls %t.cache/foo
34; RUN: not ls %t.cache/llvmcache-foo
35; RUN: ls %t.cache/llvmcache-* | count 2
36
37; Verify that enabling caching is working with llvm-lto2
38; RUN: rm -Rf %t.cache
39; RUN: llvm-lto2 run -o %t.o %t2.bc %t.bc -cache-dir %t.cache \
40; RUN:  -r=%t2.bc,_main,plx \
41; RUN:  -r=%t2.bc,_globalfunc,lx \
42; RUN:  -r=%t.bc,_globalfunc,plx
43; RUN: ls %t.cache | count 2
44; RUN: ls %t.cache/llvmcache-* | count 2
45
46; Verify that caches with a timestamp older than the pruning interval
47; will be pruned
48; RUN: rm -Rf %t.cache && mkdir %t.cache
49; RUN: touch -t 197001011200 %t.cache/llvmcache-foo
50; RUN: touch -t 197001011200 %t.cache/llvmcache.timestamp
51; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache
52; RUN: not ls %t.cache/llvmcache-foo
53
54; Verify that specifying a negative number for the pruning interval
55; effectively disables the pruning
56; RUN: rm -Rf %t.cache && mkdir %t.cache
57; RUN: touch -t 197001011200 %t.cache/llvmcache-foo
58; RUN: touch -t 197001011200 %t.cache/llvmcache.timestamp
59; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache --thinlto-cache-pruning-interval -1
60; RUN: ls %t.cache/llvmcache-foo
61
62; Verify that the pruner doesn't run and a cache file is not deleted when:
63; default values for pruning interval and cache expiration are used,
64; llvmcache.timestamp is current,
65; cache file is older than default cache expiration value.
66; RUN: rm -Rf %t.cache && mkdir %t.cache
67; RUN: touch -t 197001011200 %t.cache/llvmcache-foo
68; RUN: touch %t.cache/llvmcache.timestamp
69; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache
70; RUN: ls %t.cache/llvmcache-foo
71
72; Verify that the pruner runs and a cache file is deleted when:
73; pruning interval has value 0 (i.e. run garbage collector now)
74; default value for cache expiration is used,
75; llvmcache.timestamp is current,
76; cache file is older than default cache expiration value.
77; RUN: rm -Rf %t.cache && mkdir %t.cache
78; RUN: touch -t 197001011200 %t.cache/llvmcache-foo
79; RUN: touch %t.cache/llvmcache.timestamp
80; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache --thinlto-cache-pruning-interval 0
81; RUN: not ls %t.cache/llvmcache-foo
82
83; Populate the cache with files with "old" access times, then check llvm-lto updates these file times
84; A negative pruning interval is used to avoid removing cache entries
85; RUN: rm -Rf %t.cache && mkdir %t.cache
86; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache
87; RUN: touch -a -t 197001011200 %t.cache/llvmcache-*
88; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache --thinlto-cache-pruning-interval -1
89; RUN: ls -ltu %t.cache/* | not grep 1970-01-01
90
91; Populate the cache with files with "old" access times, then check llvm-lto2 updates these file times
92; RUN: rm -Rf %t.cache
93; RUN: llvm-lto2 run -o %t.o %t2.bc %t.bc -cache-dir %t.cache \
94; RUN:  -r=%t2.bc,_main,plx \
95; RUN:  -r=%t2.bc,_globalfunc,lx \
96; RUN:  -r=%t.bc,_globalfunc,plx
97; RUN: touch -a -t 197001011200 %t.cache/llvmcache-*
98; RUN: llvm-lto2 run -o %t.o %t2.bc %t.bc -cache-dir %t.cache \
99; RUN:  -r=%t2.bc,_main,plx \
100; RUN:  -r=%t2.bc,_globalfunc,lx \
101; RUN:  -r=%t.bc,_globalfunc,plx
102; RUN: ls -ltu %t.cache/* | not grep 1970-01-01
103
104; Verify that specifying max size for the cache directory prunes it to this
105; size, removing the largest files first.
106; RUN: rm -Rf %t.cache && mkdir %t.cache
107; Create cache files with different sizes.
108; Only 8B, 16B and 76B files should stay after pruning.
109; RUN: %python -c "with open(r'%t.cache/llvmcache-foo-1024', 'w') as file: file.truncate(1024)"
110; RUN: %python -c "with open(r'%t.cache/llvmcache-foo-16', 'w') as file: file.truncate(16)"
111; RUN: %python -c "with open(r'%t.cache/llvmcache-foo-8', 'w') as file: file.truncate(8)"
112; RUN: %python -c "with open(r'%t.cache/llvmcache-foo-76', 'w') as file: file.truncate(76)"
113; RUN: %python -c "with open(r'%t.cache/llvmcache-foo-77', 'w') as file: file.truncate(77)"
114; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache --thinlto-cache-max-size-bytes 100
115; RUN: ls %t.cache/llvmcache-foo-16
116; RUN: ls %t.cache/llvmcache-foo-8
117; RUN: ls %t.cache/llvmcache-foo-76
118; RUN: not ls %t.cache/llvmcache-foo-1024
119; RUN: not ls %t.cache/llvmcache-foo-77
120
121; Verify that specifying max number of files in the cache directory prunes
122; it to this amount, removing the largest files first.
123; RUN: rm -Rf %t.cache && mkdir %t.cache
124; Create cache files with different sizes.
125; Only 8B and 16B files should stay after pruning.
126; RUN: %python -c "print(' ' * 1023)" > %t.cache/llvmcache-foo-1024
127; RUN: %python -c "print(' ' * 15)" > %t.cache/llvmcache-foo-16
128; RUN: %python -c "print(' ' * 7)" > %t.cache/llvmcache-foo-8
129; RUN: %python -c "print(' ' * 75)" > %t.cache/llvmcache-foo-76
130; RUN: %python -c "print(' ' * 76)" > %t.cache/llvmcache-foo-77
131; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache --thinlto-cache-max-size-files 2
132; RUN: ls %t.cache/llvmcache-foo-16
133; RUN: ls %t.cache/llvmcache-foo-8
134; RUN: not ls %t.cache/llvmcache-foo-76
135; RUN: not ls %t.cache/llvmcache-foo-1024
136; RUN: not ls %t.cache/llvmcache-foo-77
137
138target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
139target triple = "x86_64-apple-macosx10.11.0"
140
141define void @globalfunc() #0 {
142entry:
143  ret void
144}
145