1*cee313d2SEric Christopher; Generate bitcode files with summary, as well as minimized bitcode without
2*cee313d2SEric Christopher; the debug metadata for the thin link.
3*cee313d2SEric Christopher; RUN: opt -thinlto-bc -thin-link-bitcode-file=%t2 -thinlto-split-lto-unit -o %t %s
4*cee313d2SEric Christopher; RUN: llvm-modextract -b -n 0 -o %t0.bc %t
5*cee313d2SEric Christopher; RUN: llvm-modextract -b -n 1 -o %t1.bc %t
6*cee313d2SEric Christopher; RUN: llvm-modextract -b -n 0 -o %t0.thinlink.bc %t2
7*cee313d2SEric Christopher; RUN: llvm-modextract -b -n 1 -o %t1.thinlink.bc %t2
8*cee313d2SEric Christopher; RUN: not llvm-modextract -b -n 2 -o - %t 2>&1 | FileCheck --check-prefix=ERROR %s
9*cee313d2SEric Christopher; RUN: llvm-dis -o - %t0.bc | FileCheck --check-prefix=M0 %s
10*cee313d2SEric Christopher; RUN: llvm-dis -o - %t1.bc | FileCheck --check-prefix=M1 %s
11*cee313d2SEric Christopher; RUN: llvm-bcanalyzer -dump %t0.bc | FileCheck --check-prefix=BCA0 %s
12*cee313d2SEric Christopher; RUN: llvm-bcanalyzer -dump %t1.bc | FileCheck --check-prefix=BCA1 %s
13*cee313d2SEric Christopher
14*cee313d2SEric Christopher; Make sure the combined index files produced by both the normal and the
15*cee313d2SEric Christopher; thin link bitcode files are identical
16*cee313d2SEric Christopher; RUN: llvm-lto -thinlto -o %t3 %t0.bc
17*cee313d2SEric Christopher; Copy the minimized bitcode to the regular bitcode path so the module
18*cee313d2SEric Christopher; paths in the index are the same.
19*cee313d2SEric Christopher; RUN: cp %t0.thinlink.bc %t0.bc
20*cee313d2SEric Christopher; RUN: llvm-lto -thinlto -o %t4 %t0.bc
21*cee313d2SEric Christopher; RUN: diff %t3.thinlto.bc %t4.thinlto.bc
22*cee313d2SEric Christopher
23*cee313d2SEric Christopher; ERROR: llvm-modextract: error: module index out of range; bitcode file contains 2 module(s)
24*cee313d2SEric Christopher
25*cee313d2SEric Christopher; BCA0: <GLOBALVAL_SUMMARY_BLOCK
26*cee313d2SEric Christopher; BCA1: <FULL_LTO_GLOBALVAL_SUMMARY_BLOCK
27*cee313d2SEric Christopher; 16 = not eligible to import
28*cee313d2SEric Christopher; BCA1: <PERMODULE_GLOBALVAR_INIT_REFS {{.*}} op1=16
29*cee313d2SEric Christopher; BCA1-NOT: <GLOBALVAL_SUMMARY_BLOCK
30*cee313d2SEric Christopher
31*cee313d2SEric Christopher$g = comdat any
32*cee313d2SEric Christopher
33*cee313d2SEric Christopher; M0: @g = external global i8{{$}}
34*cee313d2SEric Christopher; M1: @g = global i8 42, comdat, !type !0
35*cee313d2SEric Christopher@g = global i8 42, comdat, !type !0
36*cee313d2SEric Christopher
37*cee313d2SEric Christopher; M0: define i8* @f()
38*cee313d2SEric Christopher; M1-NOT: @f()
39*cee313d2SEric Christopherdefine i8* @f() {
40*cee313d2SEric Christopher  ret i8* @g
41*cee313d2SEric Christopher}
42*cee313d2SEric Christopher
43*cee313d2SEric Christopher; M1: !0 = !{i32 0, !"typeid"}
44*cee313d2SEric Christopher!0 = !{i32 0, !"typeid"}
45