1; First ensure that the ThinLTO handling in the gold plugin handles
2; bitcode without summary sections gracefully.
3; RUN: llvm-as %s -o %t.o
4; RUN: llvm-as %p/Inputs/thinlto.ll -o %t2.o
5; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
6; RUN:    --plugin-opt=thinlto \
7; RUN:    --plugin-opt=thinlto-index-only \
8; RUN:    -shared %t.o %t2.o -o %t3
9; RUN: not test -e %t3
10; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
11; RUN:    --plugin-opt=thinlto \
12; RUN:    -shared %t.o %t2.o -o %t4
13; RUN: llvm-nm %t4 | FileCheck %s --check-prefix=NM
14
15; Next generate summary sections and test gold handling.
16; RUN: opt -module-summary %s -o %t.o
17; RUN: opt -module-summary %p/Inputs/thinlto.ll -o %t2.o
18
19; Ensure gold generates an index and not a binary if requested.
20; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
21; RUN:    --plugin-opt=thinlto \
22; RUN:    --plugin-opt=thinlto-index-only \
23; RUN:    -shared %t.o %t2.o -o %t3
24; RUN: llvm-bcanalyzer -dump %t3.thinlto.bc | FileCheck %s --check-prefix=COMBINED
25; RUN: not test -e %t3
26
27; Ensure gold generates an index as well as a binary by default in ThinLTO mode.
28; First force single-threaded mode
29; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
30; RUN:    --plugin-opt=thinlto \
31; RUN:    --plugin-opt=jobs=1 \
32; RUN:    -shared %t.o %t2.o -o %t4
33; RUN: llvm-bcanalyzer -dump %t4.thinlto.bc | FileCheck %s --check-prefix=COMBINED
34; RUN: llvm-nm %t4 | FileCheck %s --check-prefix=NM
35
36; Next force multi-threaded mode
37; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
38; RUN:    --plugin-opt=thinlto \
39; RUN:    --plugin-opt=jobs=2 \
40; RUN:    -shared %t.o %t2.o -o %t4
41; RUN: llvm-bcanalyzer -dump %t4.thinlto.bc | FileCheck %s --check-prefix=COMBINED
42; RUN: llvm-nm %t4 | FileCheck %s --check-prefix=NM
43
44; Test --plugin-opt=obj-path to ensure unique object files generated.
45; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
46; RUN:    --plugin-opt=thinlto \
47; RUN:    --plugin-opt=jobs=2 \
48; RUN:    --plugin-opt=obj-path=%t5.o \
49; RUN:    -shared %t.o %t2.o -o %t4
50; RUN: llvm-nm %t5.o0 | FileCheck %s --check-prefix=NM2
51; RUN: llvm-nm %t5.o1 | FileCheck %s --check-prefix=NM2
52
53; NM: T f
54; NM2: T {{f|g}}
55
56; COMBINED: <MODULE_STRTAB_BLOCK
57; COMBINED-NEXT: <ENTRY {{.*}} record string = '{{.*}}/test/tools/gold/X86/Output/thinlto.ll.tmp{{.*}}.o'
58; COMBINED-NEXT: <ENTRY {{.*}} record string = '{{.*}}/test/tools/gold/X86/Output/thinlto.ll.tmp{{.*}}.o'
59; COMBINED-NEXT: </MODULE_STRTAB_BLOCK
60; COMBINED-NEXT: <GLOBALVAL_SUMMARY_BLOCK
61; COMBINED-NEXT: <VERSION
62; COMBINED-NEXT: <COMBINED
63; COMBINED-NEXT: <COMBINED
64; COMBINED-NEXT: </GLOBALVAL_SUMMARY_BLOCK
65; COMBINED-NEXT: <VALUE_SYMTAB
66; Check that the format is: op0=valueid, op1=offset, op2=funcguid,
67; where funcguid is the lower 64 bits of the function name MD5.
68; COMBINED-NEXT: <COMBINED_ENTRY abbrevid={{[0-9]+}} op0={{1|2}} op1={{-3706093650706652785|-5300342847281564238}}
69; COMBINED-NEXT: <COMBINED_ENTRY abbrevid={{[0-9]+}} op0={{1|2}} op1={{-3706093650706652785|-5300342847281564238}}
70; COMBINED-NEXT: </VALUE_SYMTAB
71
72declare void @g(...)
73
74define void @f() {
75entry:
76  call void (...) @g()
77  ret void
78}
79