159baf73aSVitaly Buka; RUN: rm -f %t*.o.thinlto.bc 259baf73aSVitaly Buka; RUN: rm -f %t*.o.imports 359baf73aSVitaly Buka 4d92012d5STeresa Johnson; First generate bitcode with a module summary index for each file 559baf73aSVitaly Buka; RUN: opt -module-summary %s -o %t1.o 635fa7cdfSVitaly Buka; RUN: opt -module-summary %p/Inputs/thinlto_emit_linked_objects2.ll -o %t2.o 735fa7cdfSVitaly Buka; RUN: opt %p/Inputs/thinlto_emit_linked_objects3.ll -o %t3.o 8d92012d5STeresa Johnson 9d92012d5STeresa Johnson; Next do the ThinLink step, specifying thinlto-index-only so that the gold 10d92012d5STeresa Johnson; plugin exits after generating individual indexes. The objects the linker 11d92012d5STeresa Johnson; decided to include in the link should be emitted into the file specified 1259baf73aSVitaly Buka; after 'thinlto-index-only='. In this version of the test, only %t1.o will 13d92012d5STeresa Johnson; be included in the link, and not %t2.o since it is within 14d92012d5STeresa Johnson; a library (--start-lib/--end-lib pair) and not strongly referenced. 15d92012d5STeresa Johnson; Note that the support for detecting this is in gold v1.12. 163efcfaddSEugene Leviant; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \ 17d92012d5STeresa Johnson; RUN: --plugin-opt=thinlto \ 1859baf73aSVitaly Buka; RUN: --plugin-opt=thinlto-index-only=%t.index \ 193f212b89STeresa Johnson; RUN: --plugin-opt=thinlto-emit-imports-files \ 20d92012d5STeresa Johnson; RUN: -m elf_x86_64 \ 21d92012d5STeresa Johnson; RUN: -o %t4 \ 2259baf73aSVitaly Buka; RUN: %t1.o %t3.o \ 23d92012d5STeresa Johnson; RUN: --start-lib %t2.o --end-lib 24d92012d5STeresa Johnson 253f212b89STeresa Johnson; Ensure that the expected output files are created, even for the file 263f212b89STeresa Johnson; the linker decided not to include in the link. 2759baf73aSVitaly Buka; RUN: ls %t1.o.thinlto.bc 283f212b89STeresa Johnson; RUN: ls %t2.o.thinlto.bc 2959baf73aSVitaly Buka; RUN: ls %t3.o.thinlto.bc 3059baf73aSVitaly Buka; RUN: ls %t1.o.imports 313f212b89STeresa Johnson; RUN: ls %t2.o.imports 3259baf73aSVitaly Buka; RUN: ls %t3.o.imports 333f212b89STeresa Johnson 34769134daSVitaly Buka; Regular *thinlto.bc file. "SkipModuleByDistributedBackend" flag (0x2) 35769134daSVitaly Buka; should not be set. 36769134daSVitaly Buka; RUN: llvm-bcanalyzer --dump %t1.o.thinlto.bc | FileCheck %s -check-prefixes=CHECK-BC1 37769134daSVitaly Buka; CHECK-BC1: <GLOBALVAL_SUMMARY_BLOCK 38*39db16e7SFangrui Song; CHECK-BC1: <FLAGS op0=[[#]]/> 39769134daSVitaly Buka; CHECK-BC1: </GLOBALVAL_SUMMARY_BLOCK 40769134daSVitaly Buka 41769134daSVitaly Buka; Nothing interesting in the corresponding object file, so 42769134daSVitaly Buka; "SkipModuleByDistributedBackend" flag (0x2) should be set. 43769134daSVitaly Buka; RUN: llvm-bcanalyzer --dump %t2.o.thinlto.bc | FileCheck %s -check-prefixes=CHECK-BC2 44769134daSVitaly Buka; CHECK-BC2: <GLOBALVAL_SUMMARY_BLOCK 45769134daSVitaly Buka; CHECK-BC2: <FLAGS op0=2/> 46769134daSVitaly Buka; CHECK-BC2: </GLOBALVAL_SUMMARY_BLOCK 47769134daSVitaly Buka 48769134daSVitaly Buka; Empty as the corresponding object file is not ThinTLO. 49769134daSVitaly Buka; RUN: not llvm-bcanalyzer --dump %t3.o.thinlto.bc 2>&1 | FileCheck %s -check-prefixes=CHECK-BC3 50f2055c5eSTeresa Johnson; CHECK-BC3: Unexpected end of file 51769134daSVitaly Buka 5259baf73aSVitaly Buka; RUN: cat %t.index | FileCheck %s 5359baf73aSVitaly Buka; CHECK: thinlto_emit_linked_objects.ll.tmp1.o 54d92012d5STeresa Johnson; CHECK-NOT: thinlto_emit_linked_objects.ll.tmp2.o 5559baf73aSVitaly Buka; CHECK-NOT: thinlto_emit_linked_objects.ll.tmp3.o 56d92012d5STeresa Johnson 57d92012d5STeresa Johnsontarget datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 58d92012d5STeresa Johnsontarget triple = "x86_64-unknown-linux-gnu" 59d92012d5STeresa Johnson 60d92012d5STeresa Johnsondefine i32 @main() { 61d92012d5STeresa Johnsonentry: 62d92012d5STeresa Johnson ret i32 0 63d92012d5STeresa Johnson} 64