xref: /aosp_15_r20/external/llvm/test/tools/gold/X86/thinlto.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; First ensure that the ThinLTO handling in the gold plugin handles
2*9880d681SAndroid Build Coastguard Worker; bitcode without summary sections gracefully.
3*9880d681SAndroid Build Coastguard Worker; RUN: llvm-as %s -o %t.o
4*9880d681SAndroid Build Coastguard Worker; RUN: llvm-as %p/Inputs/thinlto.ll -o %t2.o
5*9880d681SAndroid Build Coastguard Worker; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
6*9880d681SAndroid Build Coastguard Worker; RUN:    --plugin-opt=thinlto \
7*9880d681SAndroid Build Coastguard Worker; RUN:    --plugin-opt=thinlto-index-only \
8*9880d681SAndroid Build Coastguard Worker; RUN:    -shared %t.o %t2.o -o %t3
9*9880d681SAndroid Build Coastguard Worker; RUN: not test -e %t3
10*9880d681SAndroid Build Coastguard Worker; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
11*9880d681SAndroid Build Coastguard Worker; RUN:    --plugin-opt=thinlto \
12*9880d681SAndroid Build Coastguard Worker; RUN:    -shared %t.o %t2.o -o %t4
13*9880d681SAndroid Build Coastguard Worker; RUN: llvm-nm %t4 | FileCheck %s --check-prefix=NM
14*9880d681SAndroid Build Coastguard Worker
15*9880d681SAndroid Build Coastguard Worker; Next generate summary sections and test gold handling.
16*9880d681SAndroid Build Coastguard Worker; RUN: opt -module-summary %s -o %t.o
17*9880d681SAndroid Build Coastguard Worker; RUN: opt -module-summary %p/Inputs/thinlto.ll -o %t2.o
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Worker; Ensure gold generates an index and not a binary if requested.
20*9880d681SAndroid Build Coastguard Worker; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
21*9880d681SAndroid Build Coastguard Worker; RUN:    --plugin-opt=thinlto \
22*9880d681SAndroid Build Coastguard Worker; RUN:    --plugin-opt=thinlto-index-only \
23*9880d681SAndroid Build Coastguard Worker; RUN:    -shared %t.o %t2.o -o %t3
24*9880d681SAndroid Build Coastguard Worker; RUN: llvm-bcanalyzer -dump %t.o.thinlto.bc | FileCheck %s --check-prefix=BACKEND1
25*9880d681SAndroid Build Coastguard Worker; RUN: llvm-bcanalyzer -dump %t2.o.thinlto.bc | FileCheck %s --check-prefix=BACKEND2
26*9880d681SAndroid Build Coastguard Worker; RUN: not test -e %t3
27*9880d681SAndroid Build Coastguard Worker
28*9880d681SAndroid Build Coastguard Worker; Ensure gold generates an index as well as a binary by default in ThinLTO mode.
29*9880d681SAndroid Build Coastguard Worker; First force single-threaded mode
30*9880d681SAndroid Build Coastguard Worker; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
31*9880d681SAndroid Build Coastguard Worker; RUN:    --plugin-opt=thinlto \
32*9880d681SAndroid Build Coastguard Worker; RUN:    --plugin-opt=jobs=1 \
33*9880d681SAndroid Build Coastguard Worker; RUN:    -shared %t.o %t2.o -o %t4
34*9880d681SAndroid Build Coastguard Worker; RUN: llvm-bcanalyzer -dump %t4.thinlto.bc | FileCheck %s --check-prefix=COMBINED
35*9880d681SAndroid Build Coastguard Worker; RUN: llvm-nm %t4 | FileCheck %s --check-prefix=NM
36*9880d681SAndroid Build Coastguard Worker
37*9880d681SAndroid Build Coastguard Worker; Next force multi-threaded mode
38*9880d681SAndroid Build Coastguard Worker; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
39*9880d681SAndroid Build Coastguard Worker; RUN:    --plugin-opt=thinlto \
40*9880d681SAndroid Build Coastguard Worker; RUN:    --plugin-opt=jobs=2 \
41*9880d681SAndroid Build Coastguard Worker; RUN:    -shared %t.o %t2.o -o %t4
42*9880d681SAndroid Build Coastguard Worker; RUN: llvm-bcanalyzer -dump %t4.thinlto.bc | FileCheck %s --check-prefix=COMBINED
43*9880d681SAndroid Build Coastguard Worker; RUN: llvm-nm %t4 | FileCheck %s --check-prefix=NM
44*9880d681SAndroid Build Coastguard Worker
45*9880d681SAndroid Build Coastguard Worker; Test --plugin-opt=obj-path to ensure unique object files generated.
46*9880d681SAndroid Build Coastguard Worker; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
47*9880d681SAndroid Build Coastguard Worker; RUN:    --plugin-opt=thinlto \
48*9880d681SAndroid Build Coastguard Worker; RUN:    --plugin-opt=jobs=2 \
49*9880d681SAndroid Build Coastguard Worker; RUN:    --plugin-opt=obj-path=%t5.o \
50*9880d681SAndroid Build Coastguard Worker; RUN:    -shared %t.o %t2.o -o %t4
51*9880d681SAndroid Build Coastguard Worker; RUN: llvm-nm %t5.o0 | FileCheck %s --check-prefix=NM2
52*9880d681SAndroid Build Coastguard Worker; RUN: llvm-nm %t5.o1 | FileCheck %s --check-prefix=NM2
53*9880d681SAndroid Build Coastguard Worker
54*9880d681SAndroid Build Coastguard Worker; NM: T f
55*9880d681SAndroid Build Coastguard Worker; NM2: T {{f|g}}
56*9880d681SAndroid Build Coastguard Worker
57*9880d681SAndroid Build Coastguard Worker; The backend index for this module contains summaries from itself and
58*9880d681SAndroid Build Coastguard Worker; Inputs/thinlto.ll, as it imports from the latter.
59*9880d681SAndroid Build Coastguard Worker; BACKEND1: <MODULE_STRTAB_BLOCK
60*9880d681SAndroid Build Coastguard Worker; BACKEND1-NEXT: <ENTRY {{.*}} record string = '{{.*}}/test/tools/gold/X86/Output/thinlto.ll.tmp{{.*}}.o'
61*9880d681SAndroid Build Coastguard Worker; BACKEND1-NEXT: <ENTRY {{.*}} record string = '{{.*}}/test/tools/gold/X86/Output/thinlto.ll.tmp{{.*}}.o'
62*9880d681SAndroid Build Coastguard Worker; BACKEND1-NEXT: </MODULE_STRTAB_BLOCK
63*9880d681SAndroid Build Coastguard Worker; BACKEND1-NEXT: <GLOBALVAL_SUMMARY_BLOCK
64*9880d681SAndroid Build Coastguard Worker; BACKEND1-NEXT: <VERSION
65*9880d681SAndroid Build Coastguard Worker; BACKEND1-NEXT: <COMBINED
66*9880d681SAndroid Build Coastguard Worker; BACKEND1-NEXT: <COMBINED
67*9880d681SAndroid Build Coastguard Worker; BACKEND1-NEXT: </GLOBALVAL_SUMMARY_BLOCK
68*9880d681SAndroid Build Coastguard Worker; BACKEND1-NEXT: <VALUE_SYMTAB
69*9880d681SAndroid Build Coastguard Worker; Check that the format is: op0=valueid, op1=offset, op2=funcguid,
70*9880d681SAndroid Build Coastguard Worker; where funcguid is the lower 64 bits of the function name MD5.
71*9880d681SAndroid Build Coastguard Worker; BACKEND1-NEXT: <COMBINED_ENTRY abbrevid={{[0-9]+}} op0={{1|2}} op1={{-3706093650706652785|-5300342847281564238}}
72*9880d681SAndroid Build Coastguard Worker; BACKEND1-NEXT: <COMBINED_ENTRY abbrevid={{[0-9]+}} op0={{1|2}} op1={{-3706093650706652785|-5300342847281564238}}
73*9880d681SAndroid Build Coastguard Worker; BACKEND1-NEXT: </VALUE_SYMTAB
74*9880d681SAndroid Build Coastguard Worker
75*9880d681SAndroid Build Coastguard Worker; The backend index for Input/thinlto.ll contains summaries from itself only,
76*9880d681SAndroid Build Coastguard Worker; as it does not import anything.
77*9880d681SAndroid Build Coastguard Worker; BACKEND2: <MODULE_STRTAB_BLOCK
78*9880d681SAndroid Build Coastguard Worker; BACKEND2-NEXT: <ENTRY {{.*}} record string = '{{.*}}/test/tools/gold/X86/Output/thinlto.ll.tmp2.o'
79*9880d681SAndroid Build Coastguard Worker; BACKEND2-NEXT: </MODULE_STRTAB_BLOCK
80*9880d681SAndroid Build Coastguard Worker; BACKEND2-NEXT: <GLOBALVAL_SUMMARY_BLOCK
81*9880d681SAndroid Build Coastguard Worker; BACKEND2-NEXT: <VERSION
82*9880d681SAndroid Build Coastguard Worker; BACKEND2-NEXT: <COMBINED
83*9880d681SAndroid Build Coastguard Worker; BACKEND2-NEXT: </GLOBALVAL_SUMMARY_BLOCK
84*9880d681SAndroid Build Coastguard Worker; BACKEND2-NEXT: <VALUE_SYMTAB
85*9880d681SAndroid Build Coastguard Worker; Check that the format is: op0=valueid, op1=offset, op2=funcguid,
86*9880d681SAndroid Build Coastguard Worker; where funcguid is the lower 64 bits of the function name MD5.
87*9880d681SAndroid Build Coastguard Worker; BACKEND2-NEXT: <COMBINED_ENTRY abbrevid={{[0-9]+}} op0=1 op1=-5300342847281564238
88*9880d681SAndroid Build Coastguard Worker; BACKEND2-NEXT: </VALUE_SYMTAB
89*9880d681SAndroid Build Coastguard Worker
90*9880d681SAndroid Build Coastguard Worker; COMBINED: <MODULE_STRTAB_BLOCK
91*9880d681SAndroid Build Coastguard Worker; COMBINED-NEXT: <ENTRY {{.*}} record string = '{{.*}}/test/tools/gold/X86/Output/thinlto.ll.tmp{{.*}}.o'
92*9880d681SAndroid Build Coastguard Worker; COMBINED-NEXT: <ENTRY {{.*}} record string = '{{.*}}/test/tools/gold/X86/Output/thinlto.ll.tmp{{.*}}.o'
93*9880d681SAndroid Build Coastguard Worker; COMBINED-NEXT: </MODULE_STRTAB_BLOCK
94*9880d681SAndroid Build Coastguard Worker; COMBINED-NEXT: <GLOBALVAL_SUMMARY_BLOCK
95*9880d681SAndroid Build Coastguard Worker; COMBINED-NEXT: <VERSION
96*9880d681SAndroid Build Coastguard Worker; COMBINED-NEXT: <COMBINED
97*9880d681SAndroid Build Coastguard Worker; COMBINED-NEXT: <COMBINED
98*9880d681SAndroid Build Coastguard Worker; COMBINED-NEXT: </GLOBALVAL_SUMMARY_BLOCK
99*9880d681SAndroid Build Coastguard Worker; COMBINED-NEXT: <VALUE_SYMTAB
100*9880d681SAndroid Build Coastguard Worker; Check that the format is: op0=valueid, op1=offset, op2=funcguid,
101*9880d681SAndroid Build Coastguard Worker; where funcguid is the lower 64 bits of the function name MD5.
102*9880d681SAndroid Build Coastguard Worker; COMBINED-NEXT: <COMBINED_ENTRY abbrevid={{[0-9]+}} op0={{1|2}} op1={{-3706093650706652785|-5300342847281564238}}
103*9880d681SAndroid Build Coastguard Worker; COMBINED-NEXT: <COMBINED_ENTRY abbrevid={{[0-9]+}} op0={{1|2}} op1={{-3706093650706652785|-5300342847281564238}}
104*9880d681SAndroid Build Coastguard Worker; COMBINED-NEXT: </VALUE_SYMTAB
105*9880d681SAndroid Build Coastguard Worker
106*9880d681SAndroid Build Coastguard Workerdeclare void @g(...)
107*9880d681SAndroid Build Coastguard Worker
108*9880d681SAndroid Build Coastguard Workerdefine void @f() {
109*9880d681SAndroid Build Coastguard Workerentry:
110*9880d681SAndroid Build Coastguard Worker  call void (...) @g()
111*9880d681SAndroid Build Coastguard Worker  ret void
112*9880d681SAndroid Build Coastguard Worker}
113