blob: c7eebf6703e7a3d3d4cbd85a12478c9cd45808cd [file] [log] [blame]
Mehdi Aminif82bda02016-10-08 04:44:23 +00001; Verify first that *without* hash, we don't use the cache.
2
Mehdi Aminiab4a8b62016-05-14 05:16:41 +00003; RUN: opt -module-summary %s -o %t.bc
Mehdi Aminiadc0e262016-08-23 21:30:12 +00004; RUN: opt -module-summary %p/Inputs/cache.ll -o %t2.bc
Mehdi Aminiab4a8b62016-05-14 05:16:41 +00005
Mehdi Aminif82bda02016-10-08 04:44:23 +00006; Verify that enabling caching is ignoring module without hash
7; RUN: rm -Rf %t.cache && mkdir %t.cache
Ben Dunbobbin9ecb8b52017-12-19 14:42:38 +00008; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache
Mehdi Aminif82bda02016-10-08 04:44:23 +00009; 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
Peter Collingbourneab76a192017-03-02 02:02:38 +000013; RUN: rm -Rf %t.cache
Peter Collingbourne7faa60c2017-04-11 18:12:00 +000014; RUN: llvm-lto2 run -o %t.o %t2.bc %t.bc -cache-dir %t.cache \
Mehdi Aminif82bda02016-10-08 04:44:23 +000015; 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
Peter Collingbourne25a17ba2017-03-20 16:41:57 +000026; Verify that enabling caching is working, and that the pruner only removes
27; files matching the pattern "llvmcache-*".
Mehdi Aminiab4a8b62016-05-14 05:16:41 +000028; RUN: rm -Rf %t.cache && mkdir %t.cache
Peter Collingbourne25a17ba2017-03-20 16:41:57 +000029; RUN: touch -t 197001011200 %t.cache/llvmcache-foo %t.cache/foo
Ben Dunbobbin9ecb8b52017-12-19 14:42:38 +000030; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache
Peter Collingbourne25a17ba2017-03-20 16:41:57 +000031; RUN: ls %t.cache | count 4
Mehdi Aminiab4a8b62016-05-14 05:16:41 +000032; RUN: ls %t.cache/llvmcache.timestamp
Peter Collingbourne25a17ba2017-03-20 16:41:57 +000033; RUN: ls %t.cache/foo
34; RUN: not ls %t.cache/llvmcache-foo
35; RUN: ls %t.cache/llvmcache-* | count 2
Mehdi Aminiab4a8b62016-05-14 05:16:41 +000036
Mehdi Aminiadc0e262016-08-23 21:30:12 +000037; Verify that enabling caching is working with llvm-lto2
Peter Collingbourneab76a192017-03-02 02:02:38 +000038; RUN: rm -Rf %t.cache
Ben Dunbobbin9ecb8b52017-12-19 14:42:38 +000039; RUN: llvm-lto2 run -o %t.o %t2.bc %t.bc -cache-dir %t.cache \
Mehdi Aminiadc0e262016-08-23 21:30:12 +000040; 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
Peter Collingbourne25a17ba2017-03-20 16:41:57 +000044; RUN: ls %t.cache/llvmcache-* | count 2
Mehdi Aminiadc0e262016-08-23 21:30:12 +000045
Ben Dunbobbin9ecb8b52017-12-19 14:42:38 +000046; 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
Ekaterina Romanovad345f732018-02-15 23:29:21 +000062; 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
Andrew Ng089303d2018-07-04 14:17:10 +000083; 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
Ekaterina Romanovab8aeec42018-03-02 03:51:27 +0000104; Verify that specifying max size for the cache directory prunes it to this
Bob Haarman481d2242018-08-22 00:52:16 +0000105; size, removing the oldest files first.
Ekaterina Romanovab8aeec42018-03-02 03:51:27 +0000106; RUN: rm -Rf %t.cache && mkdir %t.cache
107; Create cache files with different sizes.
Bob Haarman481d2242018-08-22 00:52:16 +0000108; Only 8B and 76B files should stay after pruning.
Stella Stamenova79a40eb2018-08-27 16:33:13 +0000109; RUN: %python -c "with open(r'%t.cache/llvmcache-foo-100k', 'w') as file: file.truncate(102400)"
Bob Haarman481d2242018-08-22 00:52:16 +0000110; RUN: touch -t 198002011200 %t.cache/llvmcache-foo-100k
Stella Stamenova79a40eb2018-08-27 16:33:13 +0000111; RUN: %python -c "with open(r'%t.cache/llvmcache-foo-16', 'w') as file: file.truncate(16)"
Bob Haarman481d2242018-08-22 00:52:16 +0000112; RUN: touch -t 198002021200 %t.cache/llvmcache-foo-16
Stella Stamenova79a40eb2018-08-27 16:33:13 +0000113; RUN: %python -c "with open(r'%t.cache/llvmcache-foo-77k', 'w') as file: file.truncate(78848)"
Bob Haarman481d2242018-08-22 00:52:16 +0000114; RUN: touch -t 198002031200 %t.cache/llvmcache-foo-77k
Stella Stamenova79a40eb2018-08-27 16:33:13 +0000115; RUN: %python -c "with open(r'%t.cache/llvmcache-foo-8', 'w') as file: file.truncate(8)"
James Henderson99031b72018-10-03 13:00:20 +0000116; RUN: touch -t 198002041200 %t.cache/llvmcache-foo-8
Stella Stamenova79a40eb2018-08-27 16:33:13 +0000117; RUN: %python -c "with open(r'%t.cache/llvmcache-foo-76', 'w') as file: file.truncate(76)"
James Henderson99031b72018-10-03 13:00:20 +0000118; RUN: touch -t 198002051200 %t.cache/llvmcache-foo-76
119; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache --thinlto-cache-max-size-bytes 78847 --thinlto-cache-entry-expiration 4294967295
Ekaterina Romanovab8aeec42018-03-02 03:51:27 +0000120; RUN: ls %t.cache/llvmcache-foo-8
121; RUN: ls %t.cache/llvmcache-foo-76
Bob Haarman481d2242018-08-22 00:52:16 +0000122; RUN: not ls %t.cache/llvmcache-foo-16
123; RUN: not ls %t.cache/llvmcache-foo-100k
124; RUN: not ls %t.cache/llvmcache-foo-77k
Ekaterina Romanovab8aeec42018-03-02 03:51:27 +0000125
James Hendersone29e4082018-09-17 10:21:26 +0000126; Verify that specifying a max size > 4GB for the cache directory does not
127; prematurely prune, due to an integer overflow.
128; RUN: rm -Rf %t.cache && mkdir %t.cache
129; RUN: %python -c "with open(r'%t.cache/llvmcache-foo-10', 'w') as file: file.truncate(10)"
130; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache --thinlto-cache-max-size-bytes 4294967297
131; RUN: ls %t.cache/llvmcache-foo-10
132
133; Verify that negative numbers aren't accepted for the
134; --thinlto-cache-max-size-bytes switch
135; RUN: rm -Rf %t.cache && mkdir %t.cache
136; RUN: not llvm-lto %t.bc --thinlto-cache-max-size-bytes -1 2>&1 | FileCheck %s
137; CHECK: -thinlto-cache-max-size-bytes option: '-1' value invalid
138
Ekaterina Romanovab8aeec42018-03-02 03:51:27 +0000139; Verify that specifying max number of files in the cache directory prunes
Bob Haarman481d2242018-08-22 00:52:16 +0000140; it to this amount, removing the oldest files first.
Ekaterina Romanovab8aeec42018-03-02 03:51:27 +0000141; RUN: rm -Rf %t.cache && mkdir %t.cache
142; Create cache files with different sizes.
Bob Haarman481d2242018-08-22 00:52:16 +0000143; Only 75B and 76B files should stay after pruning.
Stella Stamenova79a40eb2018-08-27 16:33:13 +0000144; RUN: %python -c "print(' ' * 1023)" > %t.cache/llvmcache-foo-1023
Bob Haarman481d2242018-08-22 00:52:16 +0000145; RUN: touch -t 198002011200 %t.cache/llvmcache-foo-1023
Stella Stamenova79a40eb2018-08-27 16:33:13 +0000146; RUN: %python -c "print(' ' * 15)" > %t.cache/llvmcache-foo-15
Bob Haarman481d2242018-08-22 00:52:16 +0000147; RUN: touch -t 198002021200 %t.cache/llvmcache-foo-15
Stella Stamenova79a40eb2018-08-27 16:33:13 +0000148; RUN: %python -c "print(' ' * 7)" > %t.cache/llvmcache-foo-7
Bob Haarman481d2242018-08-22 00:52:16 +0000149; RUN: touch -t 198002031200 %t.cache/llvmcache-foo-7
Stella Stamenova79a40eb2018-08-27 16:33:13 +0000150; RUN: %python -c "print(' ' * 75)" > %t.cache/llvmcache-foo-75
James Henderson99031b72018-10-03 13:00:20 +0000151; RUN: touch -t 198002041200 %t.cache/llvmcache-foo-75
Stella Stamenova79a40eb2018-08-27 16:33:13 +0000152; RUN: %python -c "print(' ' * 76)" > %t.cache/llvmcache-foo-76
James Henderson99031b72018-10-03 13:00:20 +0000153; RUN: touch -t 198002051200 %t.cache/llvmcache-foo-76
154; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache --thinlto-cache-max-size-files 4 --thinlto-cache-entry-expiration 4294967295
Bob Haarman481d2242018-08-22 00:52:16 +0000155; RUN: ls %t.cache/llvmcache-foo-75
156; RUN: ls %t.cache/llvmcache-foo-76
157; RUN: not ls %t.cache/llvmcache-foo-15
Ekaterina Romanovab8aeec42018-03-02 03:51:27 +0000158; RUN: not ls %t.cache/llvmcache-foo-1024
Bob Haarman481d2242018-08-22 00:52:16 +0000159; RUN: not ls %t.cache/llvmcache-foo-7
Ekaterina Romanovab8aeec42018-03-02 03:51:27 +0000160
Mehdi Aminiab4a8b62016-05-14 05:16:41 +0000161target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
162target triple = "x86_64-apple-macosx10.11.0"
163
164define void @globalfunc() #0 {
165entry:
166 ret void
167}