100 lines · plain
1# REQUIRES: x862 3## Test that the LLD options --save-temps, --thinlto-emit-index-files,4## and --thinlto-emit-imports-files function correctly with DTLTO.5 6RUN: rm -rf %t && split-file %s %t && cd %t7 8RUN: sed 's/@t1/@t2/g' t1.ll > t2.ll9 10## Generate ThinLTO bitcode files. Note that t3.bc will not be used by the11## linker.12RUN: opt -thinlto-bc t1.ll -o t1.bc13RUN: opt -thinlto-bc t2.ll -o t2.bc14RUN: cp t1.bc t3.bc15 16## Generate object files for mock.py to return.17RUN: llc t1.ll --filetype=obj -o t1.o18RUN: llc t2.ll --filetype=obj -o t2.o19 20## Create response file containing shared ThinLTO linker arguments.21## --start-lib/--end-lib is used to test the special case where unused lazy22## bitcode inputs result in empty index/imports files.23## Note that mock.py does not do any compilation; instead, it simply writes24## the contents of the object files supplied on the command line into the25## output object files in job order.26RUN: echo "t1.bc t2.bc --start-lib t3.bc --end-lib -o my.elf \27RUN: --thinlto-distributor=\"%python\" \28RUN: --thinlto-distributor-arg=\"%llvm_src_root/utils/dtlto/mock.py\" \29RUN: --thinlto-distributor-arg=t1.o \30RUN: --thinlto-distributor-arg=t2.o" > l.rsp31 32## Check that without extra flags, no index/imports files are produced and33## backend temp files are removed.34RUN: ld.lld @l.rsp35RUN: ls | FileCheck %s \36RUN: --check-prefixes=NOBACKEND,NOINDEXFILES,NOIMPORTSFILES,NOEMPTYIMPORTS37 38## Check that index files are created with --thinlto-emit-index-files.39RUN: rm -f *.imports *.thinlto.bc40RUN: ld.lld @l.rsp --thinlto-emit-index-files41RUN: ls | sort | FileCheck %s \42RUN: --check-prefixes=NOBACKEND,INDEXFILES,NOIMPORTSFILES,NOEMPTYIMPORTS43 44## Check that imports files are created with --thinlto-emit-imports-files.45RUN: rm -f *.imports *.thinlto.bc46RUN: ld.lld @l.rsp --thinlto-emit-imports-files47RUN: ls | sort | FileCheck %s \48RUN: --check-prefixes=NOBACKEND,NOINDEXFILES,IMPORTSFILES,NOEMPTYIMPORTS49 50## Check that both index and imports files are emitted with both flags.51RUN: rm -f *.imports *.thinlto.bc52RUN: ld.lld @l.rsp --thinlto-emit-index-files \53RUN: --thinlto-emit-imports-files54RUN: ls | sort | FileCheck %s \55RUN: --check-prefixes=NOBACKEND,INDEXFILES,IMPORTSFILES,EMPTYIMPORTS56 57## Check that backend temp files are retained with --save-temps.58RUN: rm -f *.imports *.thinlto.bc59RUN: ld.lld @l.rsp --save-temps60RUN: ls | sort | FileCheck %s \61RUN: --check-prefixes=BACKEND,NOINDEXFILES,NOIMPORTSFILES,NOEMPTYIMPORTS62 63## Check that all files are emitted when all options are enabled.64RUN: rm -f *.imports *.thinlto.bc65RUN: ld.lld @l.rsp --save-temps --thinlto-emit-index-files \66RUN: --thinlto-emit-imports-files67RUN: ls | sort | FileCheck %s \68RUN: --check-prefixes=BACKEND,INDEXFILES,IMPORTSFILES,EMPTYIMPORTS69 70## JSON jobs description, retained with --save-temps.71## Note that DTLTO temporary files include a PID component.72NOBACKEND-NOT: {{^}}my.[[#]].dist-file.json{{$}}73BACKEND: {{^}}my.[[#]].dist-file.json{{$}}74 75## Index/imports files for t1.bc.76NOIMPORTSFILES-NOT: {{^}}t1.bc.imports{{$}}77IMPORTSFILES: {{^}}t1.bc.imports{{$}}78NOINDEXFILES-NOT: {{^}}t1.bc.thinlto.bc{{$}}79INDEXFILES: {{^}}t1.bc.thinlto.bc{{$}}80 81## Index/imports files for t2.bc.82NOIMPORTSFILES-NOT: {{^}}t2.bc.imports{{$}}83IMPORTSFILES: {{^}}t2.bc.imports{{$}}84NOINDEXFILES-NOT: {{^}}t2.bc.thinlto.bc{{$}}85INDEXFILES: {{^}}t2.bc.thinlto.bc{{$}}86 87## Empty index/imports files for unused t3.bc.88NOEMPTYIMPORTS-NOT: {{^}}t3.bc.imports{{$}}89EMPTYIMPORTS: {{^}}t3.bc.imports{{$}}90NOINDEXFILES-NOT: {{^}}t3.bc.thinlto.bc{{$}}91INDEXFILES: {{^}}t3.bc.thinlto.bc{{$}}92 93#--- t1.ll94target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"95target triple = "x86_64-unknown-linux-gnu"96 97define void @t1() {98 ret void99}100