brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.5 KiB · 5dd67a5 Raw
90 lines · plain
1REQUIRES: x86-registered-target, ld.lld2 3# Show that the ThinLTO cache works with DTLTO.4 5RUN: rm -rf %t && split-file %s %t && cd %t6 7# Compile source files into bitcode files.8RUN: %clang -O2 --target=x86_64-linux-gnu -flto=thin -c foo.c main.c9 10# Execute the linker and check that the cache is populated.11RUN: %clang -O2 --target=x86_64-linux-gnu -Werror -flto=thin -fuse-ld=lld -nostdlib -e main \12RUN:   main.o foo.o -o populate1.elf \13RUN:   -Wl,--thinlto-distributor=%python \14RUN:   -Wl,--thinlto-distributor-arg=%llvm_src_root/utils/dtlto/local.py \15RUN:   -Wl,--thinlto-remote-compiler=%clang \16RUN:   -Wl,--thinlto-cache-dir=cache.dir \17RUN:   -Wl,--save-temps18 19# Check that there are two backend compilation jobs occurred.20RUN: grep -wo args populate1.*.dist-file.json | wc -l | grep -qx "\s*3"21RUN: ls cache.dir/llvmcache.timestamp22RUN: ls cache.dir | count 323 24# Execute the linker again and check that a fully populated cache is used correctly, 25# i.e., no additional cache entries are created for cache hits.26RUN: %clang -O2 --target=x86_64-linux-gnu -Werror -flto=thin -fuse-ld=lld -nostdlib -e main \27RUN:   main.o foo.o -o populate2.elf \28RUN:   -Wl,--thinlto-distributor=%python \29RUN:   -Wl,--thinlto-distributor-arg=%llvm_src_root/utils/dtlto/local.py \30RUN:   -Wl,--thinlto-remote-compiler=%clang \31RUN:   -Wl,--thinlto-cache-dir=cache.dir \32RUN:   -Wl,--save-temps33 34# Check that there are no backend compilation jobs occurred.35RUN: grep -wo args populate2.*.dist-file.json | wc -l | grep -qx "\s*1"36RUN: ls cache.dir | count 337 38RUN: %clang -O0 --target=x86_64-linux-gnu -flto=thin -c foo.c -o foo.O0.o39RUN: %clang -O0 --target=x86_64-linux-gnu -flto=thin -c main.c -o main.O0.o40 41# Execute the linker again and check that the cache is populated correctly when there 42# are no cache hits but there are existing cache entries.43# As a side effect, this also verifies that the optimization level is considered when 44# evaluating the cache entry key.45 46RUN: %clang -O2 --target=x86_64-linux-gnu -Werror -flto=thin -fuse-ld=lld -nostdlib -e main \47RUN:   main.O0.o foo.O0.o -o populate3.elf \48RUN:   -Wl,--thinlto-distributor=%python \49RUN:   -Wl,--thinlto-distributor-arg=%llvm_src_root/utils/dtlto/local.py \50RUN:   -Wl,--thinlto-remote-compiler=%clang \51RUN:   -Wl,--thinlto-cache-dir=cache.dir \52RUN:   -Wl,--save-temps53 54# Check that there are two new backend compilation jobs occurred.55RUN: grep -wo args populate3.*.dist-file.json | wc -l | grep -qx "\s*3"56RUN: ls cache.dir | count 557 58RUN: %clang -O2 --target=x86_64-linux-gnu -flto=thin -c main-partial.c 59 60# Execute the linker and check that everything works correctly with the partially populated cache;61# One more cache entry should be generated after this run.62 63RUN: %clang -O2 --target=x86_64-linux-gnu -Werror -flto=thin -fuse-ld=lld -nostdlib -e main \64RUN:   main-partial.o foo.o -o main-partial.elf \65RUN:   -Wl,--thinlto-distributor=%python \66RUN:   -Wl,--thinlto-distributor-arg=%llvm_src_root/utils/dtlto/local.py \67RUN:   -Wl,--thinlto-remote-compiler=%clang \68RUN:   -Wl,--thinlto-cache-dir=cache.dir \69RUN:   -Wl,--save-temps70 71# Check that there is one new backend compilation jobs occurred.72RUN: grep -wo args main-partial.*.dist-file.json | wc -l | grep -qx "\s*2"73RUN: ls cache.dir | count 674 75#--- foo.c76volatile int foo_int;77__attribute__((retain)) int foo(int x) { return x + foo_int; }78 79#--- main.c80extern int foo(int x);81__attribute__((retain)) int main(int argc, char** argv) {82  return foo(argc);83}84 85#--- main-partial.c86extern int foo(int x);87__attribute__((retain)) int main(int argc, char** argv) {88  return foo(argc+1);89}90