blob: b65c3be14f71389e851ef837572e1a12e286403d [file] [log] [blame]
Teresa Johnson0c6a4ff2017-03-23 19:47:39 +00001; Test distributed build thin link output from llvm-lto2
Teresa Johnson0515fb82016-11-03 01:07:16 +00002
Teresa Johnson0c6a4ff2017-03-23 19:47:39 +00003; Generate bitcode files with summary, as well as minimized bitcode without
4; the debug metadata for the thin link.
5; RUN: opt -thinlto-bc %s -thin-link-bitcode-file=%t1.thinlink.bc -o %t1.bc
6; RUN: opt -thinlto-bc %p/Inputs/distributed_import.ll -thin-link-bitcode-file=%t2.thinlink.bc -o %t2.bc
Haojie Wang1dec57d2017-07-21 17:25:20 +00007; RUN: llvm-bcanalyzer -dump %t1.thinlink.bc | FileCheck --check-prefix=THINLINKBITCODE %s
Teresa Johnson0c6a4ff2017-03-23 19:47:39 +00008
9; First perform the thin link on the normal bitcode file.
Peter Collingbourne7faa60c2017-04-11 18:12:00 +000010; RUN: llvm-lto2 run %t1.bc %t2.bc -o %t.o -save-temps \
Teresa Johnson0515fb82016-11-03 01:07:16 +000011; RUN: -thinlto-distributed-indexes \
12; RUN: -r=%t1.bc,g, \
Teresa Johnson81bbf742017-12-16 00:18:12 +000013; RUN: -r=%t1.bc,analias, \
Teresa Johnson0515fb82016-11-03 01:07:16 +000014; RUN: -r=%t1.bc,f,px \
Teresa Johnson81bbf742017-12-16 00:18:12 +000015; RUN: -r=%t2.bc,g,px \
16; RUN: -r=%t2.bc,analias,px \
17; RUN: -r=%t2.bc,aliasee,px
Teresa Johnson160f4bb2017-12-16 01:35:36 +000018; RUN: opt -function-import -import-all-index -enable-import-metadata -summary-file %t1.bc.thinlto.bc %t1.bc -o %t1.out
Teresa Johnson81bbf742017-12-16 00:18:12 +000019; RUN: opt -function-import -import-all-index -summary-file %t2.bc.thinlto.bc %t2.bc -o %t2.out
20; RUN: llvm-dis -o - %t1.out | FileCheck %s --check-prefix=IMPORT
21; RUN: llvm-dis -o - %t2.out | FileCheck %s --check-prefix=EXPORT
Teresa Johnson0c6a4ff2017-03-23 19:47:39 +000022
23; Save the generated index files.
24; RUN: cp %t1.bc.thinlto.bc %t1.bc.thinlto.bc.orig
25; RUN: cp %t2.bc.thinlto.bc %t2.bc.thinlto.bc.orig
26
27; Copy the minimized bitcode to the regular bitcode path so the module
28; paths in the index are the same (save the regular bitcode for use again
29; further down).
30; RUN: cp %t1.bc %t1.bc.sv
31; RUN: cp %t1.thinlink.bc %t1.bc
32; RUN: cp %t2.bc %t2.bc.sv
33; RUN: cp %t2.thinlink.bc %t2.bc
34
35; Next perform the thin link on the minimized bitcode files, and compare dumps
36; of the resulting indexes to the above dumps to ensure they are identical.
37; RUN: rm -f %t1.bc.thinlto.bc %t2.bc.thinlto.bc
Peter Collingbourne7faa60c2017-04-11 18:12:00 +000038; RUN: llvm-lto2 run %t1.bc %t2.bc -o %t.o -save-temps \
Teresa Johnson0c6a4ff2017-03-23 19:47:39 +000039; RUN: -thinlto-distributed-indexes \
40; RUN: -r=%t1.bc,g, \
Teresa Johnson81bbf742017-12-16 00:18:12 +000041; RUN: -r=%t1.bc,analias, \
Teresa Johnson0c6a4ff2017-03-23 19:47:39 +000042; RUN: -r=%t1.bc,f,px \
Teresa Johnson81bbf742017-12-16 00:18:12 +000043; RUN: -r=%t2.bc,g,px \
44; RUN: -r=%t2.bc,analias,px \
45; RUN: -r=%t2.bc,aliasee,px
Teresa Johnson0c6a4ff2017-03-23 19:47:39 +000046; RUN: diff %t1.bc.thinlto.bc.orig %t1.bc.thinlto.bc
47; RUN: diff %t2.bc.thinlto.bc.orig %t2.bc.thinlto.bc
48
49; Make sure importing occurs as expected
50; RUN: cp %t1.bc.sv %t1.bc
51; RUN: cp %t2.bc.sv %t2.bc
Teresa Johnson4358a402017-12-16 01:00:48 +000052; RUN: opt -function-import -import-all-index -enable-import-metadata -summary-file %t1.bc.thinlto.bc %t1.bc -o %t1.out
Teresa Johnson81bbf742017-12-16 00:18:12 +000053; RUN: opt -function-import -import-all-index -summary-file %t2.bc.thinlto.bc %t2.bc -o %t2.out
54; RUN: llvm-dis -o - %t1.out | FileCheck %s --check-prefix=IMPORT
55; RUN: llvm-dis -o - %t2.out | FileCheck %s --check-prefix=EXPORT
Teresa Johnson0c6a4ff2017-03-23 19:47:39 +000056
Teresa Johnson81bbf742017-12-16 00:18:12 +000057; IMPORT: define available_externally i32 @g() !thinlto_src_module
58; IMPORT: define available_externally void @analias() !thinlto_src_module
59; EXPORT: @G.llvm.
Teresa Johnson0515fb82016-11-03 01:07:16 +000060
Vitaly Bukaa5376f32017-12-16 02:10:00 +000061target triple = "x86_64-unknown-linux-gnu"
Amy Huang7b1d7932019-09-10 23:15:38 +000062target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
Davide Italiano2ceb6282016-12-14 21:57:04 +000063
Teresa Johnson0515fb82016-11-03 01:07:16 +000064declare i32 @g(...)
Teresa Johnson81bbf742017-12-16 00:18:12 +000065declare void @analias(...)
Teresa Johnson0515fb82016-11-03 01:07:16 +000066
67define void @f() {
68entry:
69 call i32 (...) @g()
Teresa Johnson81bbf742017-12-16 00:18:12 +000070 call void (...) @analias()
Teresa Johnson0515fb82016-11-03 01:07:16 +000071 ret void
72}
Teresa Johnson0c6a4ff2017-03-23 19:47:39 +000073
Haojie Wang1dec57d2017-07-21 17:25:20 +000074; THINLINKBITCODE-NOT: IDENTIFICATION_BLOCK_ID
75; THINLINKBITCODE-NOT: BLOCKINFO_BLOCK
76; THINLINKBITCODE-NOT: TYPE_BLOCK_ID
77; THINLINKBITCODE-NOT: VSTOFFSET
78; THINLINKBITCODE-NOT: CONSTANTS_BLOCK
79; THINLINKBITCODE-NOT: METADATA_KIND_BLOCK
80; THINLINKBITCODE-NOT: METADATA_BLOCK
81; THINLINKBITCODE-NOT: OPERAND_BUNDLE_TAGS_BLOCK
82; THINLINKBITCODE-NOT: UnknownBlock26
83; THINLINKBITCODE-NOT: FUNCTION_BLOCK
84; THINLINKBITCODE-NOT: VALUE_SYMTAB
85; THINLINKBITCODE: MODULE_BLOCK
86; THINLINKBITCODE: VERSION
87; THINLINKBITCODE: SOURCE_FILENAME
88; THINLINKBITCODE: GLOBALVAL_SUMMARY_BLOCK
89; THINLINKBITCODE: HASH
90; THINLINKBITCODE: SYMTAB_BLOCK
91; THINLINKBITCODE: STRTAB_BLOCK
92
Teresa Johnson0c6a4ff2017-03-23 19:47:39 +000093!llvm.dbg.cu = !{}
94
95!1 = !{i32 2, !"Debug Info Version", i32 3}
96!llvm.module.flags = !{!1}