1; REQUIRES: shell 2 3; RUN: opt -module-hash -module-summary %s -o %t.o 4; RUN: opt -module-hash -module-summary %p/Inputs/cache.ll -o %t2.o 5 6; RUN: rm -rf %t && mkdir %t 7 8;; Check cache policies of the number of files. 9;; Case 1: A value of 0 disables the number of files based pruning. Therefore, there is no warning. 10; RUN: wasm-ld --verbose --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_files=0 %t2.o %t.o -o %t3 2>&1 | FileCheck %s --implicit-check-not=warning: 11;; Case 2: If the total number of the files created by the current link job is less than the maximum number of files, there is no warning. 12; RUN: wasm-ld --verbose --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_files=3 %t2.o %t.o -o %t3 2>&1 | FileCheck %s --implicit-check-not=warning: 13;; Case 3: If the total number of the files created by the current link job exceeds the maximum number of files, a warning is given. 14; RUN: wasm-ld --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_files=1 %t2.o %t.o -o %t3 2>&1 | FileCheck %s --check-prefixes=NUM,WARN 15 16;; Check cache policies of the cache size. 17;; Case 1: A value of 0 disables the absolute size-based pruning. Therefore, there is no warning. 18; RUN: wasm-ld --verbose --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_bytes=0 %t2.o %t.o -o %t3 2>&1 | FileCheck %s --implicit-check-not=warning: 19 20;; Get the total size of created cache files. 21; RUN: rm -rf %t && mkdir %t && cd %t 22; RUN: wasm-ld --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_bytes=32k %t2.o %t.o -o %t3 2>&1 23; RUN: %python -c "import os, sys; print(sum(os.path.getsize(filename) for filename in os.listdir('.') if os.path.isfile(filename) and filename.startswith('llvmcache-')))" > %t.size.txt 24 25;; Case 2: If the total size of the cache files created by the current link job is less than the maximum size for the cache directory in bytes, there is no warning. 26; RUN: wasm-ld --verbose --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_bytes=$(($(cat %t.size.txt) + 5)) %t2.o %t.o -o %t3 2>&1 | FileCheck %s --implicit-check-not=warning: 27 28;; Case 3: If the total size of the cache files created by the current link job exceeds the maximum size for the cache directory in bytes, a warning is given. 29; RUN: wasm-ld --verbose --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_bytes=$(($(cat %t.size.txt) - 5)) %t2.o %t.o -o %t3 2>&1 | FileCheck %s --check-prefixes=SIZE,WARN 30 31;; Check emit two warnings if pruning happens due to reach both the size and number limits. 32; RUN: wasm-ld --thinlto-cache-dir=%t --thinlto-cache-policy=prune_interval=0s:cache_size_files=1:cache_size_bytes=1 %t2.o %t.o -o %t3 2>&1 | FileCheck %s --check-prefixes=NUM,SIZE,WARN 33 34; NUM: warning: ThinLTO cache pruning happens since the number of{{.*}}--thinlto-cache-policy 35; SIZE: warning: ThinLTO cache pruning happens since the total size of{{.*}}--thinlto-cache-policy 36; WARN-NOT: warning: ThinLTO cache pruning happens{{.*}}--thinlto-cache-policy 37 38target triple = "wasm32-unknown-unknown-wasm" 39 40define void @globalfunc() #0 { 41entry: 42 ret void 43} 44