xref: /llvm-project/llvm/test/Transforms/ThinLTOBitcodeWriter/split-vfunc.ll (revision 9950ea66203849df25352b8db8f4ea108ef47a5a)
16699029bSArthur Eubanks; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t %s
2cee313d2SEric Christopher; RUN: llvm-modextract -b -n 0 -o - %t | llvm-dis | FileCheck --check-prefix=M0 %s
3cee313d2SEric Christopher; RUN: llvm-modextract -b -n 1 -o - %t | llvm-dis | FileCheck --check-prefix=M1 %s
4cee313d2SEric Christopher
5*9950ea66SNikita Popov; M0: @g = external constant [10 x ptr]{{$}}
6*9950ea66SNikita Popov; M1: @g = constant [10 x ptr]
7*9950ea66SNikita Popov@g = constant [10 x ptr] [
8*9950ea66SNikita Popov  ptr @ok1,
9*9950ea66SNikita Popov  ptr @ok2,
10*9950ea66SNikita Popov  ptr @wrongtype1,
11*9950ea66SNikita Popov  ptr @wrongtype2,
12*9950ea66SNikita Popov  ptr @wrongtype3,
13*9950ea66SNikita Popov  ptr @wrongtype4,
14*9950ea66SNikita Popov  ptr @wrongtype5,
15*9950ea66SNikita Popov  ptr @usesthis,
16*9950ea66SNikita Popov  ptr @reads,
17*9950ea66SNikita Popov  ptr @attributedFunc
18cee313d2SEric Christopher], !type !0
19cee313d2SEric Christopher
20cee313d2SEric Christopher; M0: define i64 @ok1
21cee313d2SEric Christopher; M1: define available_externally i64 @ok1
22*9950ea66SNikita Popovdefine i64 @ok1(ptr %this) {
23cee313d2SEric Christopher  ret i64 42
24cee313d2SEric Christopher}
25cee313d2SEric Christopher
26cee313d2SEric Christopher; M0: define i64 @ok2
27cee313d2SEric Christopher; M1: define available_externally i64 @ok2
28*9950ea66SNikita Popovdefine i64 @ok2(ptr %this, i64 %arg) {
29cee313d2SEric Christopher  %1 = tail call { i64, i1 } @llvm.sadd.with.overflow.i64(i64 %arg, i64 %arg)
30cee313d2SEric Christopher  ret i64 %arg
31cee313d2SEric Christopher}
32cee313d2SEric Christopher
33cee313d2SEric Christopher; M1: declare { i64, i1 } @llvm.sadd.with.overflow.i64(i64, i64)
34cee313d2SEric Christopherdeclare { i64, i1 } @llvm.sadd.with.overflow.i64(i64, i64)
35cee313d2SEric Christopher
36cee313d2SEric Christopher; M0: define void @wrongtype1
37cee313d2SEric Christopher; M1: declare void @wrongtype1()
38*9950ea66SNikita Popovdefine void @wrongtype1(ptr) {
39cee313d2SEric Christopher  ret void
40cee313d2SEric Christopher}
41cee313d2SEric Christopher
42cee313d2SEric Christopher; M0: define i128 @wrongtype2
43cee313d2SEric Christopher; M1: declare void @wrongtype2()
44*9950ea66SNikita Popovdefine i128 @wrongtype2(ptr) {
45cee313d2SEric Christopher  ret i128 0
46cee313d2SEric Christopher}
47cee313d2SEric Christopher
48cee313d2SEric Christopher; M0: define i64 @wrongtype3
49cee313d2SEric Christopher; M1: declare void @wrongtype3()
50cee313d2SEric Christopherdefine i64 @wrongtype3() {
51cee313d2SEric Christopher  ret i64 0
52cee313d2SEric Christopher}
53cee313d2SEric Christopher
54cee313d2SEric Christopher; M0: define i64 @wrongtype4
55cee313d2SEric Christopher; M1: declare void @wrongtype4()
56*9950ea66SNikita Popovdefine i64 @wrongtype4(ptr, ptr) {
57cee313d2SEric Christopher  ret i64 0
58cee313d2SEric Christopher}
59cee313d2SEric Christopher
60cee313d2SEric Christopher; M0: define i64 @wrongtype5
61cee313d2SEric Christopher; M1: declare void @wrongtype5()
62*9950ea66SNikita Popovdefine i64 @wrongtype5(ptr, i128) {
63cee313d2SEric Christopher  ret i64 0
64cee313d2SEric Christopher}
65cee313d2SEric Christopher
66cee313d2SEric Christopher; M0: define i64 @usesthis
67cee313d2SEric Christopher; M1: declare void @usesthis()
68*9950ea66SNikita Popovdefine i64 @usesthis(ptr %this) {
69*9950ea66SNikita Popov  %i = ptrtoint ptr %this to i64
70cee313d2SEric Christopher  ret i64 %i
71cee313d2SEric Christopher}
72cee313d2SEric Christopher
73cee313d2SEric Christopher; M0: define i8 @reads
74cee313d2SEric Christopher; M1: declare void @reads()
75*9950ea66SNikita Popovdefine i8 @reads(ptr %this) {
76*9950ea66SNikita Popov  %l = load i8, ptr %this
77cee313d2SEric Christopher  ret i8 %l
78cee313d2SEric Christopher}
79cee313d2SEric Christopher
80e28435caSZequan Wu; Check function attributes are copied over splitted module
81*9950ea66SNikita Popov; M0: declare dso_local noundef ptr @attributedFunc(ptr noalias, i8 zeroext) unnamed_addr #[[ATTR0:[0-9]+]]
82e28435caSZequan Wu; M1: declare dso_local void @attributedFunc() unnamed_addr #[[ATTR1:[0-9]+]]
83*9950ea66SNikita Popovdeclare dso_local noundef ptr @attributedFunc(ptr noalias, i8 zeroext) unnamed_addr alwaysinline willreturn
84e28435caSZequan Wu; M0: attributes #[[ATTR0]] = { alwaysinline willreturn }
85e28435caSZequan Wu; M1: attributes #[[ATTR1]] = { alwaysinline willreturn }
86e28435caSZequan Wu
87cee313d2SEric Christopher!0 = !{i32 0, !"typeid"}
88