| 1 |
REQUIRES: x86-registered-target, ld.lld |
| 2 |
|
| 3 |
# This test verifies that a cache populated by an in-process ThinLTO codegen is |
| 4 |
# not reused by an out-of-process (DTLTO) codegen and vice versa. |
| 5 |
|
| 6 |
RUN: rm -rf %t && split-file %s %t && cd %t |
| 7 |
|
| 8 |
# Compile source files into bitcode files. |
| 9 |
RUN: %clang -O2 --target=x86_64-linux-gnu -flto=thin -c foo.c main.c |
| 10 |
|
| 11 |
# Execute the linker and check that in-process ThinLTO cache is populated. |
| 12 |
RUN: %clang -O2 --target=x86_64-linux-gnu -Werror -flto=thin -fuse-ld=lld -nostdlib -e main \ |
| 13 |
RUN: main.o foo.o -o main.elf \ |
| 14 |
RUN: -Wl,--thinlto-cache-dir=cache.dir \ |
| 15 |
RUN: -Wl,--save-temps |
| 16 |
|
| 17 |
RUN: ls cache.dir/llvmcache.timestamp |
| 18 |
RUN: ls cache.dir | count 3 |
| 19 |
|
| 20 |
# Execute the linker and check that out-of-process codegen (DTLTO) adds |
| 21 |
# additional entries to the cache, implying that in-process and |
| 22 |
# out-of-process codegens do not share cache entries. |
| 23 |
RUN: %clang -O2 --target=x86_64-linux-gnu -Werror -flto=thin -fuse-ld=lld -nostdlib -e main \ |
| 24 |
RUN: main.o foo.o -o populate1.elf \ |
| 25 |
RUN: -Wl,--thinlto-distributor=%python \ |
| 26 |
RUN: -Wl,--thinlto-distributor-arg=%llvm_src_root/utils/dtlto/local.py \ |
| 27 |
RUN: -Wl,--thinlto-remote-compiler=%clang \ |
| 28 |
RUN: -Wl,--thinlto-cache-dir=cache.dir \ |
| 29 |
RUN: -Wl,--save-temps |
| 30 |
|
| 31 |
# Check that there are two backend compilation jobs occurred. |
| 32 |
RUN: grep -wo args populate1.*.dist-file.json | wc -l | grep -qx "\s*3" |
| 33 |
RUN: ls cache.dir | count 5 |
| 34 |
|
| 35 |
# Clean up cache directory. |
| 36 |
RUN: rm -rf cache.dir |
| 37 |
|
| 38 |
# Execute the linker and check that out-of-process (DTLTO) cache is populated. |
| 39 |
RUN: %clang -O2 --target=x86_64-linux-gnu -Werror -flto=thin -fuse-ld=lld -nostdlib -e main \ |
| 40 |
RUN: main.o foo.o -o populate2.elf \ |
| 41 |
RUN: -Wl,--thinlto-distributor=%python \ |
| 42 |
RUN: -Wl,--thinlto-distributor-arg=%llvm_src_root/utils/dtlto/local.py \ |
| 43 |
RUN: -Wl,--thinlto-remote-compiler=%clang \ |
| 44 |
RUN: -Wl,--thinlto-cache-dir=cache.dir \ |
| 45 |
RUN: -Wl,--save-temps |
| 46 |
|
| 47 |
# Check that there are two backend compilation jobs occurred. |
| 48 |
RUN: grep -wo args populate2.*.dist-file.json | wc -l | grep -qx "\s*3" |
| 49 |
RUN: ls cache.dir/llvmcache.timestamp |
| 50 |
RUN: ls cache.dir | count 3 |
| 51 |
|
| 52 |
# Execute the linker and check that in-process codegen adds additional entries |
| 53 |
# to the cache, implying that in-process and out-of-process codegens do |
| 54 |
# not share cache entries. |
| 55 |
RUN: %clang -O2 --target=x86_64-linux-gnu -Werror -flto=thin -fuse-ld=lld -nostdlib -e main \ |
| 56 |
RUN: main.o foo.o -o main.elf \ |
| 57 |
RUN: -Wl,--thinlto-cache-dir=cache.dir \ |
| 58 |
RUN: -Wl,--save-temps |
| 59 |
|
| 60 |
RUN: ls cache.dir | count 5 |
| 61 |
|
| 62 |
#--- foo.c |
| 63 |
volatile int foo_int; |
| 64 |
__attribute__((retain)) int foo(int x) { return x + foo_int; } |
| 65 |
|
| 66 |
#--- main.c |
| 67 |
extern int foo(int x); |
| 68 |
__attribute__((retain)) int main(int argc, char** argv) { |
| 69 |
return foo(argc); |
| 70 |
} |