Michal Gorny | 929ce27 | 2018-12-05 11:15:50 +0000 | [diff] [blame] | 1 | ; NetBSD: noatime mounts currently inhibit 'touch -a' updates |
| 2 | ; UNSUPPORTED: system-netbsd |
Mehdi Amini | f82bda0 | 2016-10-08 04:44:23 +0000 | [diff] [blame] | 3 | |
Michal Gorny | 929ce27 | 2018-12-05 11:15:50 +0000 | [diff] [blame] | 4 | ; Verify first that *without* hash, we don't use the cache. |
Mehdi Amini | ab4a8b6 | 2016-05-14 05:16:41 +0000 | [diff] [blame] | 5 | ; RUN: opt -module-summary %s -o %t.bc |
Mehdi Amini | adc0e26 | 2016-08-23 21:30:12 +0000 | [diff] [blame] | 6 | ; RUN: opt -module-summary %p/Inputs/cache.ll -o %t2.bc |
Mehdi Amini | ab4a8b6 | 2016-05-14 05:16:41 +0000 | [diff] [blame] | 7 | |
Mehdi Amini | f82bda0 | 2016-10-08 04:44:23 +0000 | [diff] [blame] | 8 | ; Verify that enabling caching is ignoring module without hash |
| 9 | ; RUN: rm -Rf %t.cache && mkdir %t.cache |
Ben Dunbobbin | 9ecb8b5 | 2017-12-19 14:42:38 +0000 | [diff] [blame] | 10 | ; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache |
Mehdi Amini | f82bda0 | 2016-10-08 04:44:23 +0000 | [diff] [blame] | 11 | ; 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 Collingbourne | ab76a19 | 2017-03-02 02:02:38 +0000 | [diff] [blame] | 15 | ; RUN: rm -Rf %t.cache |
Peter Collingbourne | 7faa60c | 2017-04-11 18:12:00 +0000 | [diff] [blame] | 16 | ; RUN: llvm-lto2 run -o %t.o %t2.bc %t.bc -cache-dir %t.cache \ |
Mehdi Amini | f82bda0 | 2016-10-08 04:44:23 +0000 | [diff] [blame] | 17 | ; 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 Collingbourne | 25a17ba | 2017-03-20 16:41:57 +0000 | [diff] [blame] | 28 | ; Verify that enabling caching is working, and that the pruner only removes |
| 29 | ; files matching the pattern "llvmcache-*". |
Mehdi Amini | ab4a8b6 | 2016-05-14 05:16:41 +0000 | [diff] [blame] | 30 | ; RUN: rm -Rf %t.cache && mkdir %t.cache |
Peter Collingbourne | 25a17ba | 2017-03-20 16:41:57 +0000 | [diff] [blame] | 31 | ; RUN: touch -t 197001011200 %t.cache/llvmcache-foo %t.cache/foo |
Ben Dunbobbin | 9ecb8b5 | 2017-12-19 14:42:38 +0000 | [diff] [blame] | 32 | ; RUN: llvm-lto -thinlto-action=run -exported-symbol=globalfunc %t2.bc %t.bc -thinlto-cache-dir %t.cache |
Peter Collingbourne | 25a17ba | 2017-03-20 16:41:57 +0000 | [diff] [blame] | 33 | ; RUN: ls %t.cache | count 4 |
Mehdi Amini | ab4a8b6 | 2016-05-14 05:16:41 +0000 | [diff] [blame] | 34 | ; RUN: ls %t.cache/llvmcache.timestamp |
Peter Collingbourne | 25a17ba | 2017-03-20 16:41:57 +0000 | [diff] [blame] | 35 | ; RUN: ls %t.cache/foo |
| 36 | ; RUN: not ls %t.cache/llvmcache-foo |
| 37 | ; RUN: ls %t.cache/llvmcache-* | count 2 |
Mehdi Amini | ab4a8b6 | 2016-05-14 05:16:41 +0000 | [diff] [blame] | 38 | |
Mehdi Amini | adc0e26 | 2016-08-23 21:30:12 +0000 | [diff] [blame] | 39 | ; Verify that enabling caching is working with llvm-lto2 |
Peter Collingbourne | ab76a19 | 2017-03-02 02:02:38 +0000 | [diff] [blame] | 40 | ; RUN: rm -Rf %t.cache |
Ben Dunbobbin | 9ecb8b5 | 2017-12-19 14:42:38 +0000 | [diff] [blame] | 41 | ; RUN: llvm-lto2 run -o %t.o %t2.bc %t.bc -cache-dir %t.cache \ |
Mehdi Amini | adc0e26 | 2016-08-23 21:30:12 +0000 | [diff] [blame] | 42 | ; 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 Collingbourne | 25a17ba | 2017-03-20 16:41:57 +0000 | [diff] [blame] | 46 | ; RUN: ls %t.cache/llvmcache-* | count 2 |
Mehdi Amini | adc0e26 | 2016-08-23 21:30:12 +0000 | [diff] [blame] | 47 | |
Ben Dunbobbin | 9ecb8b5 | 2017-12-19 14:42:38 +0000 | [diff] [blame] | 48 | ; 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 Romanova | d345f73 | 2018-02-15 23:29:21 +0000 | [diff] [blame] | 64 | ; 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 Ng | 089303d | 2018-07-04 14:17:10 +0000 | [diff] [blame] | 85 | ; 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 Romanova | b8aeec4 | 2018-03-02 03:51:27 +0000 | [diff] [blame] | 106 | ; Verify that specifying max size for the cache directory prunes it to this |
Bob Haarman | 481d224 | 2018-08-22 00:52:16 +0000 | [diff] [blame] | 107 | ; size, removing the oldest files first. |
Ekaterina Romanova | b8aeec4 | 2018-03-02 03:51:27 +0000 | [diff] [blame] | 108 | ; RUN: rm -Rf %t.cache && mkdir %t.cache |
| 109 | ; Create cache files with different sizes. |
Bob Haarman | 481d224 | 2018-08-22 00:52:16 +0000 | [diff] [blame] | 110 | ; Only 8B and 76B files should stay after pruning. |
Stella Stamenova | 79a40eb | 2018-08-27 16:33:13 +0000 | [diff] [blame] | 111 | ; RUN: %python -c "with open(r'%t.cache/llvmcache-foo-100k', 'w') as file: file.truncate(102400)" |
Bob Haarman | 481d224 | 2018-08-22 00:52:16 +0000 | [diff] [blame] | 112 | ; RUN: touch -t 198002011200 %t.cache/llvmcache-foo-100k |
Stella Stamenova | 79a40eb | 2018-08-27 16:33:13 +0000 | [diff] [blame] | 113 | ; RUN: %python -c "with open(r'%t.cache/llvmcache-foo-16', 'w') as file: file.truncate(16)" |
Bob Haarman | 481d224 | 2018-08-22 00:52:16 +0000 | [diff] [blame] | 114 | ; RUN: touch -t 198002021200 %t.cache/llvmcache-foo-16 |
Stella Stamenova | 79a40eb | 2018-08-27 16:33:13 +0000 | [diff] [blame] | 115 | ; RUN: %python -c "with open(r'%t.cache/llvmcache-foo-77k', 'w') as file: file.truncate(78848)" |
Bob Haarman | 481d224 | 2018-08-22 00:52:16 +0000 | [diff] [blame] | 116 | ; RUN: touch -t 198002031200 %t.cache/llvmcache-foo-77k |
Stella Stamenova | 79a40eb | 2018-08-27 16:33:13 +0000 | [diff] [blame] | 117 | ; RUN: %python -c "with open(r'%t.cache/llvmcache-foo-8', 'w') as file: file.truncate(8)" |
James Henderson | 99031b7 | 2018-10-03 13:00:20 +0000 | [diff] [blame] | 118 | ; RUN: touch -t 198002041200 %t.cache/llvmcache-foo-8 |
Stella Stamenova | 79a40eb | 2018-08-27 16:33:13 +0000 | [diff] [blame] | 119 | ; RUN: %python -c "with open(r'%t.cache/llvmcache-foo-76', 'w') as file: file.truncate(76)" |
James Henderson | 99031b7 | 2018-10-03 13:00:20 +0000 | [diff] [blame] | 120 | ; 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 Romanova | b8aeec4 | 2018-03-02 03:51:27 +0000 | [diff] [blame] | 122 | ; RUN: ls %t.cache/llvmcache-foo-8 |
| 123 | ; RUN: ls %t.cache/llvmcache-foo-76 |
Bob Haarman | 481d224 | 2018-08-22 00:52:16 +0000 | [diff] [blame] | 124 | ; 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 Romanova | b8aeec4 | 2018-03-02 03:51:27 +0000 | [diff] [blame] | 127 | |
James Henderson | e29e408 | 2018-09-17 10:21:26 +0000 | [diff] [blame] | 128 | ; 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 Romanova | b8aeec4 | 2018-03-02 03:51:27 +0000 | [diff] [blame] | 141 | ; Verify that specifying max number of files in the cache directory prunes |
Bob Haarman | 481d224 | 2018-08-22 00:52:16 +0000 | [diff] [blame] | 142 | ; it to this amount, removing the oldest files first. |
Ekaterina Romanova | b8aeec4 | 2018-03-02 03:51:27 +0000 | [diff] [blame] | 143 | ; RUN: rm -Rf %t.cache && mkdir %t.cache |
| 144 | ; Create cache files with different sizes. |
Bob Haarman | 481d224 | 2018-08-22 00:52:16 +0000 | [diff] [blame] | 145 | ; Only 75B and 76B files should stay after pruning. |
Stella Stamenova | 79a40eb | 2018-08-27 16:33:13 +0000 | [diff] [blame] | 146 | ; RUN: %python -c "print(' ' * 1023)" > %t.cache/llvmcache-foo-1023 |
Bob Haarman | 481d224 | 2018-08-22 00:52:16 +0000 | [diff] [blame] | 147 | ; RUN: touch -t 198002011200 %t.cache/llvmcache-foo-1023 |
Stella Stamenova | 79a40eb | 2018-08-27 16:33:13 +0000 | [diff] [blame] | 148 | ; RUN: %python -c "print(' ' * 15)" > %t.cache/llvmcache-foo-15 |
Bob Haarman | 481d224 | 2018-08-22 00:52:16 +0000 | [diff] [blame] | 149 | ; RUN: touch -t 198002021200 %t.cache/llvmcache-foo-15 |
Stella Stamenova | 79a40eb | 2018-08-27 16:33:13 +0000 | [diff] [blame] | 150 | ; RUN: %python -c "print(' ' * 7)" > %t.cache/llvmcache-foo-7 |
Bob Haarman | 481d224 | 2018-08-22 00:52:16 +0000 | [diff] [blame] | 151 | ; RUN: touch -t 198002031200 %t.cache/llvmcache-foo-7 |
Stella Stamenova | 79a40eb | 2018-08-27 16:33:13 +0000 | [diff] [blame] | 152 | ; RUN: %python -c "print(' ' * 75)" > %t.cache/llvmcache-foo-75 |
James Henderson | 99031b7 | 2018-10-03 13:00:20 +0000 | [diff] [blame] | 153 | ; RUN: touch -t 198002041200 %t.cache/llvmcache-foo-75 |
Stella Stamenova | 79a40eb | 2018-08-27 16:33:13 +0000 | [diff] [blame] | 154 | ; RUN: %python -c "print(' ' * 76)" > %t.cache/llvmcache-foo-76 |
James Henderson | 99031b7 | 2018-10-03 13:00:20 +0000 | [diff] [blame] | 155 | ; 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 Haarman | 481d224 | 2018-08-22 00:52:16 +0000 | [diff] [blame] | 157 | ; 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 Romanova | b8aeec4 | 2018-03-02 03:51:27 +0000 | [diff] [blame] | 160 | ; RUN: not ls %t.cache/llvmcache-foo-1024 |
Bob Haarman | 481d224 | 2018-08-22 00:52:16 +0000 | [diff] [blame] | 161 | ; RUN: not ls %t.cache/llvmcache-foo-7 |
Ekaterina Romanova | b8aeec4 | 2018-03-02 03:51:27 +0000 | [diff] [blame] | 162 | |
Mehdi Amini | ab4a8b6 | 2016-05-14 05:16:41 +0000 | [diff] [blame] | 163 | target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" |
| 164 | target triple = "x86_64-apple-macosx10.11.0" |
| 165 | |
| 166 | define void @globalfunc() #0 { |
| 167 | entry: |
| 168 | ret void |
| 169 | } |