1*ca875cb4SYing Yi; REQUIRES: shell 2*ca875cb4SYing Yi 3*ca875cb4SYing Yi; RUN: opt -module-hash -module-summary %s -o %t.o 4*ca875cb4SYing Yi; RUN: opt -module-hash -module-summary %p/Inputs/cache.ll -o %t2.o 5*ca875cb4SYing Yi 6*ca875cb4SYing Yi; RUN: rm -rf %t && mkdir %t 7*ca875cb4SYing Yi 8*ca875cb4SYing Yi;; Check cache policies of the number of files. 9*ca875cb4SYing Yi;; Case 1: A value of 0 disables the number of files based pruning. Therefore, there is no warning. 10*ca875cb4SYing Yi; 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*ca875cb4SYing Yi;; 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*ca875cb4SYing Yi; 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*ca875cb4SYing Yi;; 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*ca875cb4SYing Yi; 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*ca875cb4SYing Yi 16*ca875cb4SYing Yi;; Check cache policies of the cache size. 17*ca875cb4SYing Yi;; Case 1: A value of 0 disables the absolute size-based pruning. Therefore, there is no warning. 18*ca875cb4SYing Yi; 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*ca875cb4SYing Yi 20*ca875cb4SYing Yi;; Get the total size of created cache files. 21*ca875cb4SYing Yi; RUN: rm -rf %t && mkdir %t && cd %t 22*ca875cb4SYing Yi; 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*ca875cb4SYing Yi; 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*ca875cb4SYing Yi 25*ca875cb4SYing Yi;; 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*ca875cb4SYing Yi; 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*ca875cb4SYing Yi 28*ca875cb4SYing Yi;; 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*ca875cb4SYing Yi; 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*ca875cb4SYing Yi 31*ca875cb4SYing Yi;; Check emit two warnings if pruning happens due to reach both the size and number limits. 32*ca875cb4SYing Yi; 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*ca875cb4SYing Yi 34*ca875cb4SYing Yi; NUM: warning: ThinLTO cache pruning happens since the number of{{.*}}--thinlto-cache-policy 35*ca875cb4SYing Yi; SIZE: warning: ThinLTO cache pruning happens since the total size of{{.*}}--thinlto-cache-policy 36*ca875cb4SYing Yi; WARN-NOT: warning: ThinLTO cache pruning happens{{.*}}--thinlto-cache-policy 37*ca875cb4SYing Yi 38*ca875cb4SYing Yitarget triple = "wasm32-unknown-unknown-wasm" 39*ca875cb4SYing Yi 40*ca875cb4SYing Yidefine void @globalfunc() #0 { 41*ca875cb4SYing Yientry: 42*ca875cb4SYing Yi ret void 43*ca875cb4SYing Yi} 44