xref: /llvm-project/llvm/test/ThinLTO/X86/distributed_import.ll (revision a9af1b9a307780a39facd016c7329990d6cc5508)
1; Test distributed build thin link output from llvm-lto2
2
3; Generate bitcode files with summary, as well as minimized bitcode containing just the summary
4; RUN: opt -thinlto-bc %s -thin-link-bitcode-file=%t1.thinlink.bc -o %t1.bc
5; RUN: opt -thinlto-bc %p/Inputs/distributed_import.ll -thin-link-bitcode-file=%t2.thinlink.bc -o %t2.bc
6; RUN: llvm-bcanalyzer -dump %t1.thinlink.bc | FileCheck --check-prefix=THINLINKBITCODE %s
7
8; First perform the thin link on the normal bitcode file.
9; RUN: llvm-lto2 run %t1.bc %t2.bc -o %t.o -save-temps \
10; RUN:     -thinlto-distributed-indexes \
11; RUN:     -r=%t1.bc,g, \
12; RUN:     -r=%t1.bc,analias, \
13; RUN:     -r=%t1.bc,f,px \
14; RUN:     -r=%t2.bc,g,px \
15; RUN:     -r=%t2.bc,analias,px \
16; RUN:     -r=%t2.bc,aliasee,px
17; RUN: opt -passes=function-import -import-all-index -enable-import-metadata -summary-file %t1.bc.thinlto.bc %t1.bc -o %t1.out
18; RUN: opt -passes=function-import -import-all-index -summary-file %t2.bc.thinlto.bc %t2.bc -o %t2.out
19; RUN: llvm-dis -o - %t1.out | FileCheck %s --check-prefix=IMPORT
20; RUN: llvm-dis -o - %t2.out | FileCheck %s --check-prefix=EXPORT
21
22; Save the generated index files.
23; RUN: cp %t1.bc.thinlto.bc %t1.bc.thinlto.bc.orig
24; RUN: cp %t2.bc.thinlto.bc %t2.bc.thinlto.bc.orig
25
26; Copy the minimized bitcode to the regular bitcode path so the module
27; paths in the index are the same (save the regular bitcode for use again
28; further down).
29; RUN: cp %t1.bc %t1.bc.sv
30; RUN: cp %t1.thinlink.bc %t1.bc
31; RUN: cp %t2.bc %t2.bc.sv
32; RUN: cp %t2.thinlink.bc %t2.bc
33
34; Next perform the thin link on the minimized bitcode files, and compare dumps
35; of the resulting indexes to the above dumps to ensure they are identical.
36; RUN: rm -f %t1.bc.thinlto.bc %t2.bc.thinlto.bc
37; RUN: llvm-lto2 run %t1.bc %t2.bc -o %t.o -save-temps \
38; RUN:     -thinlto-distributed-indexes \
39; RUN:     -r=%t1.bc,g, \
40; RUN:     -r=%t1.bc,analias, \
41; RUN:     -r=%t1.bc,f,px \
42; RUN:     -r=%t2.bc,g,px \
43; RUN:     -r=%t2.bc,analias,px \
44; RUN:     -r=%t2.bc,aliasee,px
45; RUN: diff %t1.bc.thinlto.bc.orig %t1.bc.thinlto.bc
46; RUN: diff %t2.bc.thinlto.bc.orig %t2.bc.thinlto.bc
47
48; Make sure importing occurs as expected
49; RUN: cp %t1.bc.sv %t1.bc
50; RUN: cp %t2.bc.sv %t2.bc
51; RUN: opt -passes=function-import -import-all-index -enable-import-metadata -summary-file %t1.bc.thinlto.bc %t1.bc -o %t1.out
52; RUN: opt -passes=function-import -import-all-index -summary-file %t2.bc.thinlto.bc %t2.bc -o %t2.out
53; RUN: llvm-dis -o - %t1.out | FileCheck %s --check-prefix=IMPORT
54; RUN: llvm-dis -o - %t2.out | FileCheck %s --check-prefix=EXPORT
55
56; IMPORT: define available_externally i32 @g() !thinlto_src_module
57; IMPORT: define available_externally void @analias() !thinlto_src_module
58; EXPORT: @G.llvm.
59
60target triple = "x86_64-unknown-linux-gnu"
61target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
62
63declare i32 @g(...)
64declare void @analias(...)
65
66define void @f() {
67entry:
68  call i32 (...) @g()
69  call void (...) @analias()
70  ret void
71}
72
73; THINLINKBITCODE-NOT: IDENTIFICATION_BLOCK_ID
74; THINLINKBITCODE-NOT: BLOCKINFO_BLOCK
75; THINLINKBITCODE-NOT: TYPE_BLOCK_ID
76; THINLINKBITCODE-NOT: VSTOFFSET
77; THINLINKBITCODE-NOT: CONSTANTS_BLOCK
78; THINLINKBITCODE-NOT: METADATA_KIND_BLOCK
79; THINLINKBITCODE-NOT: METADATA_BLOCK
80; THINLINKBITCODE-NOT: OPERAND_BUNDLE_TAGS_BLOCK
81; THINLINKBITCODE-NOT: UnknownBlock26
82; THINLINKBITCODE-NOT: FUNCTION_BLOCK
83; THINLINKBITCODE-NOT: VALUE_SYMTAB
84; THINLINKBITCODE: MODULE_BLOCK
85; THINLINKBITCODE: VERSION
86; THINLINKBITCODE: SOURCE_FILENAME
87; THINLINKBITCODE: GLOBALVAL_SUMMARY_BLOCK
88; THINLINKBITCODE: HASH
89; THINLINKBITCODE: SYMTAB_BLOCK
90; THINLINKBITCODE: STRTAB_BLOCK
91
92!llvm.dbg.cu = !{}
93
94!1 = !{i32 2, !"Debug Info Version", i32 3}
95!llvm.module.flags = !{!1}
96