blob: 75e6b7fd6be76c3f31086cd0abb6266b275f5c03 [file] [log] [blame]
Michal Gorny929ce272018-12-05 11:15:50 +00001; NetBSD: noatime mounts currently inhibit 'touch -a' updates
2; UNSUPPORTED: system-netbsd
Mehdi Aminif82bda02016-10-08 04:44:23 +00003
Michal Gorny929ce272018-12-05 11:15:50 +00004; Verify first that *without* hash, we don't use the cache.
Mehdi Aminiab4a8b62016-05-14 05:16:41 +00005; RUN: opt -module-summary %s -o %t.bc
Mehdi Aminiadc0e262016-08-23 21:30:12 +00006; RUN: opt -module-summary %p/Inputs/cache.ll -o %t2.bc
Mehdi Aminiab4a8b62016-05-14 05:16:41 +00007
Mehdi Aminif82bda02016-10-08 04:44:23 +00008; Verify that enabling caching is ignoring module without hash
9; RUN: rm -Rf %t.cache && mkdir %t.cache
Ben Dunbobbin9ecb8b52017-12-19 14:42:38 +000010; 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 +000011; RUN: ls %t.cache/llvmcache.timestamp
12; RUN: ls %t.cache | count 1
13
14; Verify that enabling caching is ignoring module without hash with llvm-lto2
Peter Collingbourneab76a192017-03-02 02:02:38 +000015; RUN: rm -Rf %t.cache
Peter Collingbourne7faa60c2017-04-11 18:12:00 +000016; RUN: llvm-lto2 run -o %t.o %t2.bc %t.bc -cache-dir %t.cache \
Mehdi Aminif82bda02016-10-08 04:44:23 +000017; RUN: -r=%t2.bc,_main,plx \
18; RUN: -r=%t2.bc,_globalfunc,lx \
19; RUN: -r=%t.bc,_globalfunc,plx
20; RUN: ls %t.cache | count 0
21
22
23; Repeat again, *with* hash this time.
24
25; RUN: opt -module-hash -module-summary %s -o %t.bc
26; RUN: opt -module-hash -module-summary %p/Inputs/cache.ll -o %t2.bc
27
Peter Collingbourne25a17ba2017-03-20 16:41:57 +000028; Verify that enabling caching is working, and that the pruner only removes
29; files matching the pattern "llvmcache-*".
Mehdi Aminiab4a8b62016-05-14 05:16:41 +000030; RUN: rm -Rf %t.cache && mkdir %t.cache
Peter Collingbourne25a17ba2017-03-20 16:41:57 +000031; RUN: touch -t 197001011200 %t.cache/llvmcache-foo %t.cache/foo
Ben Dunbobbin9ecb8b52017-12-19 14:42:38 +000032; 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 +000033; RUN: ls %t.cache | count 4
Mehdi Aminiab4a8b62016-05-14 05:16:41 +000034; RUN: ls %t.cache/llvmcache.timestamp
Peter Collingbourne25a17ba2017-03-20 16:41:57 +000035; RUN: ls %t.cache/foo
36; RUN: not ls %t.cache/llvmcache-foo
37; RUN: ls %t.cache/llvmcache-* | count 2
Mehdi Aminiab4a8b62016-05-14 05:16:41 +000038
Mehdi Aminiadc0e262016-08-23 21:30:12 +000039; Verify that enabling caching is working with llvm-lto2
Peter Collingbourneab76a192017-03-02 02:02:38 +000040; RUN: rm -Rf %t.cache
Ben Dunbobbin9ecb8b52017-12-19 14:42:38 +000041; RUN: llvm-lto2 run -o %t.o %t2.bc %t.bc -cache-dir %t.cache \
Mehdi Aminiadc0e262016-08-23 21:30:12 +000042; RUN: -r=%t2.bc,_main,plx \
43; RUN: -r=%t2.bc,_globalfunc,lx \
44; RUN: -r=%t.bc,_globalfunc,plx
45; RUN: ls %t.cache | count 2
Peter Collingbourne25a17ba2017-03-20 16:41:57 +000046; RUN: ls %t.cache/llvmcache-* | count 2
Mehdi Aminiadc0e262016-08-23 21:30:12 +000047
Ben Dunbobbin9ecb8b52017-12-19 14:42:38 +000048; Verify that caches with a timestamp older than the pruning interval
49; will be pruned
50; RUN: rm -Rf %t.cache && mkdir %t.cache
51; RUN: touch -t 197001011200 %t.cache/llvmcache-foo
52; RUN: touch -t 197001011200 %t.cache/llvmcache.timestamp
53; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache
54; RUN: not ls %t.cache/llvmcache-foo
55
56; Verify that specifying a negative number for the pruning interval
57; effectively disables the pruning
58; RUN: rm -Rf %t.cache && mkdir %t.cache
59; RUN: touch -t 197001011200 %t.cache/llvmcache-foo
60; RUN: touch -t 197001011200 %t.cache/llvmcache.timestamp
61; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache --thinlto-cache-pruning-interval -1
62; RUN: ls %t.cache/llvmcache-foo
63
Ekaterina Romanovad345f732018-02-15 23:29:21 +000064; Verify that the pruner doesn't run and a cache file is not deleted when:
65; default values for pruning interval and cache expiration are used,
66; llvmcache.timestamp is current,
67; cache file is older than default cache expiration value.
68; RUN: rm -Rf %t.cache && mkdir %t.cache
69; RUN: touch -t 197001011200 %t.cache/llvmcache-foo
70; RUN: touch %t.cache/llvmcache.timestamp
71; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache
72; RUN: ls %t.cache/llvmcache-foo
73
74; Verify that the pruner runs and a cache file is deleted when:
75; pruning interval has value 0 (i.e. run garbage collector now)
76; default value for cache expiration is used,
77; llvmcache.timestamp is current,
78; cache file is older than default cache expiration value.
79; RUN: rm -Rf %t.cache && mkdir %t.cache
80; RUN: touch -t 197001011200 %t.cache/llvmcache-foo
81; RUN: touch %t.cache/llvmcache.timestamp
82; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache --thinlto-cache-pruning-interval 0
83; RUN: not ls %t.cache/llvmcache-foo
84
Andrew Ng089303d2018-07-04 14:17:10 +000085; Populate the cache with files with "old" access times, then check llvm-lto updates these file times
86; A negative pruning interval is used to avoid removing cache entries
87; RUN: rm -Rf %t.cache && mkdir %t.cache
88; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache
89; RUN: touch -a -t 197001011200 %t.cache/llvmcache-*
90; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache --thinlto-cache-pruning-interval -1
91; RUN: ls -ltu %t.cache/* | not grep 1970-01-01
92
93; Populate the cache with files with "old" access times, then check llvm-lto2 updates these file times
94; RUN: rm -Rf %t.cache
95; RUN: llvm-lto2 run -o %t.o %t2.bc %t.bc -cache-dir %t.cache \
96; RUN: -r=%t2.bc,_main,plx \
97; RUN: -r=%t2.bc,_globalfunc,lx \
98; RUN: -r=%t.bc,_globalfunc,plx
99; RUN: touch -a -t 197001011200 %t.cache/llvmcache-*
100; RUN: llvm-lto2 run -o %t.o %t2.bc %t.bc -cache-dir %t.cache \
101; RUN: -r=%t2.bc,_main,plx \
102; RUN: -r=%t2.bc,_globalfunc,lx \
103; RUN: -r=%t.bc,_globalfunc,plx
104; RUN: ls -ltu %t.cache/* | not grep 1970-01-01
105
Ekaterina Romanovab8aeec42018-03-02 03:51:27 +0000106; Verify that specifying max size for the cache directory prunes it to this
Bob Haarman481d2242018-08-22 00:52:16 +0000107; size, removing the oldest files first.
Ekaterina Romanovab8aeec42018-03-02 03:51:27 +0000108; RUN: rm -Rf %t.cache && mkdir %t.cache
109; Create cache files with different sizes.
Bob Haarman481d2242018-08-22 00:52:16 +0000110; Only 8B and 76B files should stay after pruning.
Stella Stamenova79a40eb2018-08-27 16:33:13 +0000111; RUN: %python -c "with open(r'%t.cache/llvmcache-foo-100k', 'w') as file: file.truncate(102400)"
Bob Haarman481d2242018-08-22 00:52:16 +0000112; RUN: touch -t 198002011200 %t.cache/llvmcache-foo-100k
Stella Stamenova79a40eb2018-08-27 16:33:13 +0000113; RUN: %python -c "with open(r'%t.cache/llvmcache-foo-16', 'w') as file: file.truncate(16)"
Bob Haarman481d2242018-08-22 00:52:16 +0000114; RUN: touch -t 198002021200 %t.cache/llvmcache-foo-16
Stella Stamenova79a40eb2018-08-27 16:33:13 +0000115; RUN: %python -c "with open(r'%t.cache/llvmcache-foo-77k', 'w') as file: file.truncate(78848)"
Bob Haarman481d2242018-08-22 00:52:16 +0000116; RUN: touch -t 198002031200 %t.cache/llvmcache-foo-77k
Stella Stamenova79a40eb2018-08-27 16:33:13 +0000117; RUN: %python -c "with open(r'%t.cache/llvmcache-foo-8', 'w') as file: file.truncate(8)"
James Henderson99031b72018-10-03 13:00:20 +0000118; RUN: touch -t 198002041200 %t.cache/llvmcache-foo-8
Stella Stamenova79a40eb2018-08-27 16:33:13 +0000119; RUN: %python -c "with open(r'%t.cache/llvmcache-foo-76', 'w') as file: file.truncate(76)"
James Henderson99031b72018-10-03 13:00:20 +0000120; RUN: touch -t 198002051200 %t.cache/llvmcache-foo-76
121; 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 +0000122; RUN: ls %t.cache/llvmcache-foo-8
123; RUN: ls %t.cache/llvmcache-foo-76
Bob Haarman481d2242018-08-22 00:52:16 +0000124; RUN: not ls %t.cache/llvmcache-foo-16
125; RUN: not ls %t.cache/llvmcache-foo-100k
126; RUN: not ls %t.cache/llvmcache-foo-77k
Ekaterina Romanovab8aeec42018-03-02 03:51:27 +0000127
James Hendersone29e4082018-09-17 10:21:26 +0000128; Verify that specifying a max size > 4GB for the cache directory does not
129; prematurely prune, due to an integer overflow.
130; RUN: rm -Rf %t.cache && mkdir %t.cache
131; RUN: %python -c "with open(r'%t.cache/llvmcache-foo-10', 'w') as file: file.truncate(10)"
132; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache --thinlto-cache-max-size-bytes 4294967297
133; RUN: ls %t.cache/llvmcache-foo-10
134
135; Verify that negative numbers aren't accepted for the
136; --thinlto-cache-max-size-bytes switch
137; RUN: rm -Rf %t.cache && mkdir %t.cache
138; RUN: not llvm-lto %t.bc --thinlto-cache-max-size-bytes -1 2>&1 | FileCheck %s
139; CHECK: -thinlto-cache-max-size-bytes option: '-1' value invalid
140
Ekaterina Romanovab8aeec42018-03-02 03:51:27 +0000141; Verify that specifying max number of files in the cache directory prunes
Bob Haarman481d2242018-08-22 00:52:16 +0000142; it to this amount, removing the oldest files first.
Ekaterina Romanovab8aeec42018-03-02 03:51:27 +0000143; RUN: rm -Rf %t.cache && mkdir %t.cache
144; Create cache files with different sizes.
Bob Haarman481d2242018-08-22 00:52:16 +0000145; Only 75B and 76B files should stay after pruning.
Stella Stamenova79a40eb2018-08-27 16:33:13 +0000146; RUN: %python -c "print(' ' * 1023)" > %t.cache/llvmcache-foo-1023
Bob Haarman481d2242018-08-22 00:52:16 +0000147; RUN: touch -t 198002011200 %t.cache/llvmcache-foo-1023
Stella Stamenova79a40eb2018-08-27 16:33:13 +0000148; RUN: %python -c "print(' ' * 15)" > %t.cache/llvmcache-foo-15
Bob Haarman481d2242018-08-22 00:52:16 +0000149; RUN: touch -t 198002021200 %t.cache/llvmcache-foo-15
Stella Stamenova79a40eb2018-08-27 16:33:13 +0000150; RUN: %python -c "print(' ' * 7)" > %t.cache/llvmcache-foo-7
Bob Haarman481d2242018-08-22 00:52:16 +0000151; RUN: touch -t 198002031200 %t.cache/llvmcache-foo-7
Stella Stamenova79a40eb2018-08-27 16:33:13 +0000152; RUN: %python -c "print(' ' * 75)" > %t.cache/llvmcache-foo-75
James Henderson99031b72018-10-03 13:00:20 +0000153; RUN: touch -t 198002041200 %t.cache/llvmcache-foo-75
Stella Stamenova79a40eb2018-08-27 16:33:13 +0000154; RUN: %python -c "print(' ' * 76)" > %t.cache/llvmcache-foo-76
James Henderson99031b72018-10-03 13:00:20 +0000155; RUN: touch -t 198002051200 %t.cache/llvmcache-foo-76
156; 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 +0000157; RUN: ls %t.cache/llvmcache-foo-75
158; RUN: ls %t.cache/llvmcache-foo-76
159; RUN: not ls %t.cache/llvmcache-foo-15
Ekaterina Romanovab8aeec42018-03-02 03:51:27 +0000160; RUN: not ls %t.cache/llvmcache-foo-1024
Bob Haarman481d2242018-08-22 00:52:16 +0000161; RUN: not ls %t.cache/llvmcache-foo-7
Ekaterina Romanovab8aeec42018-03-02 03:51:27 +0000162
Mehdi Aminiab4a8b62016-05-14 05:16:41 +0000163target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
164target triple = "x86_64-apple-macosx10.11.0"
165
166define void @globalfunc() #0 {
167entry:
168 ret void
169}