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%shlibext \
7 ; RUN: --plugin-opt=thinlto \
8 ; RUN: --plugin-opt=thinlto-index-only \
9 ; RUN: -shared %t.o %t2.o -o %t3
10 ; RUN: not test -e %t3
11 ; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \
12 ; RUN: -m elf_x86_64 \
13 ; RUN: --plugin-opt=thinlto \
14 ; RUN: -shared %t.o %t2.o -o %t4
15 ; RUN: llvm-nm %t4 | FileCheck %s --check-prefix=NM
17 ; Next generate summary sections and test gold handling.
18 ; RUN: opt -module-summary %s -o %t.o
19 ; RUN: opt -module-summary %p/Inputs/thinlto.ll -o %t2.o
21 ; Ensure gold generates an index and not a binary if requested.
22 ; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \
23 ; RUN: -m elf_x86_64 \
24 ; RUN: --plugin-opt=thinlto \
25 ; RUN: --plugin-opt=thinlto-index-only \
26 ; RUN: -shared %t.o %t2.o -o %t3
27 ; RUN: llvm-bcanalyzer -dump %t.o.thinlto.bc | FileCheck %s --check-prefix=BACKEND1
28 ; RUN: llvm-bcanalyzer -dump %t2.o.thinlto.bc | FileCheck %s --check-prefix=BACKEND2
29 ; RUN: llvm-dis %t.o.thinlto.bc -o - | FileCheck %s --check-prefix=DIS1
30 ; RUN: llvm-dis %t2.o.thinlto.bc -o - | FileCheck %s --check-prefix=DIS2
31 ; RUN: not test -e %t3
33 ; Ensure gold generates an index as well as a binary with save-temps in ThinLTO mode.
34 ; First force single-threaded mode
36 ; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \
37 ; RUN: -m elf_x86_64 \
38 ; RUN: --plugin-opt=save-temps \
39 ; RUN: --plugin-opt=thinlto \
40 ; RUN: --plugin-opt=jobs=1 \
41 ; RUN: -shared %t.o %t2.o -o %t4
42 ; RUN: llvm-bcanalyzer -dump %t4.index.bc | FileCheck %s --check-prefix=COMBINED
43 ; RUN: llvm-nm %t4 | FileCheck %s --check-prefix=NM
44 ; Ensure ld does not emit empty combined module in default.
45 ; RUN: ls %t4.lto.o* | count 2
47 ; Check with --no-map-whole-files
48 ; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \
49 ; RUN: -m elf_x86_64 \
50 ; RUN: --plugin-opt=save-temps \
51 ; RUN: --plugin-opt=thinlto \
52 ; RUN: --plugin-opt=jobs=1 \
53 ; RUN: --no-map-whole-files \
54 ; RUN: -shared %t.o %t2.o -o %t4
55 ; RUN: llvm-bcanalyzer -dump %t4.index.bc | FileCheck %s --check-prefix=COMBINED
56 ; RUN: llvm-nm %t4 | FileCheck %s --check-prefix=NM
58 ; Next force multi-threaded mode
59 ; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \
60 ; RUN: -m elf_x86_64 \
61 ; RUN: --plugin-opt=save-temps \
62 ; RUN: --plugin-opt=thinlto \
63 ; RUN: --plugin-opt=jobs=2 \
64 ; RUN: -shared %t.o %t2.o -o %t4
65 ; RUN: llvm-bcanalyzer -dump %t4.index.bc | FileCheck %s --check-prefix=COMBINED
66 ; RUN: llvm-nm %t4 | FileCheck %s --check-prefix=NM
68 ; Test --plugin-opt=obj-path to ensure unique object files generated.
69 ; RUN: rm -f %t5.o %t5.o1
70 ; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \
71 ; RUN: -m elf_x86_64 \
72 ; RUN: --plugin-opt=thinlto \
73 ; RUN: --plugin-opt=jobs=2 \
74 ; RUN: --plugin-opt=obj-path=%t5.o \
75 ; RUN: -shared %t.o %t2.o -o %t4
76 ; RUN: llvm-nm %t5.o1 | FileCheck %s --check-prefix=NM2
77 ; RUN: llvm-nm %t5.o2 | FileCheck %s --check-prefix=NM2
78 ; Ensure ld emits empty combined module if specific obj-path.
79 ; RUN: ls %t5.o* | count 3
81 ; Test to ensure that thinlto-index-only with obj-path creates the file.
82 ; RUN: rm -f %t5.o %t5.o1
83 ; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \
84 ; RUN: -m elf_x86_64 \
85 ; RUN: --plugin-opt=thinlto \
86 ; RUN: --plugin-opt=jobs=2 \
87 ; RUN: --plugin-opt=thinlto-index-only \
88 ; RUN: --plugin-opt=obj-path=%t5.o \
89 ; RUN: -shared %t.o %t2.o -o %t4
90 ; RUN: llvm-readobj -h %t5.o | FileCheck %s --check-prefix=FORMAT
91 ; RUN: llvm-nm %t5.o 2>&1 | count 0
95 ; FORMAT: Format: elf64-x86-64
97 ; The backend index for this module contains summaries from itself and
98 ; Inputs/thinlto.ll, as it imports from the latter.
99 ; BACKEND1: <MODULE_STRTAB_BLOCK
100 ; BACKEND1-NEXT: <ENTRY {{.*}} record string = '{{.*}}/test/tools/gold/X86/Output/thinlto.ll.tmp{{.*}}.o'
101 ; BACKEND1-NEXT: <ENTRY {{.*}} record string = '{{.*}}/test/tools/gold/X86/Output/thinlto.ll.tmp{{.*}}.o'
102 ; BACKEND1-NEXT: </MODULE_STRTAB_BLOCK
103 ; BACKEND1-NEXT: <GLOBALVAL_SUMMARY_BLOCK
104 ; BACKEND1-NEXT: <VERSION
105 ; BACKEND1-NEXT: <FLAGS
106 ; BACKEND1-NEXT: <VALUE_GUID {{.*}} op0={{1|2}} {{op1=3060885059 op2=1207956914|op1=3432075125 op2=3712786831}}
107 ; BACKEND1-NEXT: <VALUE_GUID {{.*}} op0={{1|2}} {{op1=3060885059 op2=1207956914|op1=3432075125 op2=3712786831}}
108 ; BACKEND1-NEXT: <COMBINED
109 ; BACKEND1-NEXT: <COMBINED
110 ; BACKEND1-NEXT: </GLOBALVAL_SUMMARY_BLOCK
112 ; The backend index for Input/thinlto.ll contains summaries from itself only,
113 ; as it does not import anything.
114 ; BACKEND2: <MODULE_STRTAB_BLOCK
115 ; BACKEND2-NEXT: <ENTRY {{.*}} record string = '{{.*}}/test/tools/gold/X86/Output/thinlto.ll.tmp2.o'
116 ; BACKEND2-NEXT: </MODULE_STRTAB_BLOCK
117 ; BACKEND2-NEXT: <GLOBALVAL_SUMMARY_BLOCK
118 ; BACKEND2-NEXT: <VERSION
119 ; BACKEND2-NEXT: <FLAGS
120 ; BACKEND2-NEXT: <VALUE_GUID {{.*}} op0=1 op1=3060885059 op2=1207956914
121 ; BACKEND2-NEXT: <COMBINED
122 ; BACKEND2-NEXT: </GLOBALVAL_SUMMARY_BLOCK
124 ; DIS1: ^0 = module: (path: "{{.*}}thinlto.ll.tmp.o", hash: (0, 0, 0, 0, 0))
125 ; DIS1: ^1 = module: (path: "{{.*}}thinlto.ll.tmp2.o", hash: (0, 0, 0, 0, 0))
126 ; DIS1: ^2 = gv: (guid: 13146401226427987378, summaries: (function: (module: ^1, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 1, dsoLocal: 0, canAutoHide: 0, importType: definition), insts: 1)))
127 ; DIS1: ^3 = gv: (guid: 14740650423002898831, summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 1, dsoLocal: 0, canAutoHide: 0, importType: definition), insts: 2, calls: ((callee: ^2)))))
129 ; DIS2: ^0 = module: (path: "{{.*}}thinlto.ll.tmp2.o", hash: (0, 0, 0, 0, 0))
130 ; DIS2: ^1 = gv: (guid: 13146401226427987378, summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 1, dsoLocal: 0, canAutoHide: 0, importType: definition), insts: 1)))
132 ; COMBINED: <MODULE_STRTAB_BLOCK
133 ; COMBINED-NEXT: <ENTRY {{.*}} record string = '{{.*}}/test/tools/gold/X86/Output/thinlto.ll.tmp{{.*}}.o'
134 ; COMBINED-NEXT: <ENTRY {{.*}} record string = '{{.*}}/test/tools/gold/X86/Output/thinlto.ll.tmp{{.*}}.o'
135 ; COMBINED-NEXT: </MODULE_STRTAB_BLOCK
136 ; COMBINED-NEXT: <GLOBALVAL_SUMMARY_BLOCK
137 ; COMBINED-NEXT: <VERSION
138 ; COMBINED-NEXT: <FLAGS
139 ; COMBINED-NEXT: <VALUE_GUID {{.*}} op0={{1|2}} {{op1=3060885059 op2=1207956914|op1=3432075125 op2=3712786831}}
140 ; COMBINED-NEXT: <VALUE_GUID {{.*}} op0={{1|2}} {{op1=3060885059 op2=1207956914|op1=3432075125 op2=3712786831}}
141 ; COMBINED-NEXT: <COMBINED
142 ; COMBINED-NEXT: <COMBINED
143 ; COMBINED-NEXT: </GLOBALVAL_SUMMARY_BLOCK
145 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
146 target triple = "x86_64-unknown-linux-gnu"