1; RUN: opt -module-summary %s -o %t.o
2; RUN: llvm-bcanalyzer -dump %t.o | FileCheck %s
3; RUN: llvm-dis -o - %t.o | FileCheck %s --check-prefix=DIS
4; RUN: llvm-lto -thinlto -o %t2 %t.o
5; RUN: llvm-bcanalyzer -dump %t2.thinlto.bc | FileCheck --check-prefix=COMBINED %s
6; RUN: llvm-dis -o - %t2.thinlto.bc | FileCheck %s --check-prefix=COMBINED-DIS
7
8target datalayout = "e-p:64:64"
9target triple = "x86_64-unknown-linux-gnu"
10
11; COMBINED:      <TYPE_TEST_ASSUME_VCALLS op0=6699318081062747564 op1=16/>
12; COMBINED-NEXT: <COMBINED
13; COMBINED-NEXT: <TYPE_CHECKED_LOAD_VCALLS op0=6699318081062747564 op1=16/>
14; COMBINED-NEXT: <COMBINED
15; COMBINED-NEXT: <TYPE_TEST_ASSUME_VCALLS op0=6699318081062747564 op1=24 op2=-2012135647395072713 op3=32/>
16; COMBINED-NEXT: <COMBINED
17; COMBINED-NEXT: <TYPE_TEST_ASSUME_CONST_VCALL op0=6699318081062747564 op1=16 op2=42/>
18; COMBINED-NEXT: <TYPE_TEST_ASSUME_CONST_VCALL op0=6699318081062747564 op1=24 op2=43/>
19; COMBINED-NEXT: <COMBINED
20; COMBINED-NEXT: <TYPE_CHECKED_LOAD_CONST_VCALL op0=6699318081062747564 op1=16 op2=42/>
21; COMBINED-NEXT: <COMBINED
22; COMBINED-NEXT: <TYPE_TESTS op0=7546896869197086323/>
23; COMBINED-NEXT: <COMBINED
24
25; CHECK: <TYPE_TEST_ASSUME_VCALLS op0=6699318081062747564 op1=16/>
26define void @f1([3 x i8*]* %vtable) {
27  %vtablei8 = bitcast [3 x i8*]* %vtable to i8*
28  %p = call i1 @llvm.type.test(i8* %vtablei8, metadata !"foo")
29  call void @llvm.assume(i1 %p)
30  %fptrptr = getelementptr [3 x i8*], [3 x i8*]* %vtable, i32 0, i32 2
31  %fptr = load i8*, i8** %fptrptr
32  %fptr_casted = bitcast i8* %fptr to void (i8*, i32)*
33  call void %fptr_casted(i8* null, i32 undef)
34  ret void
35}
36
37; CHECK: <TYPE_TEST_ASSUME_VCALLS op0=6699318081062747564 op1=24 op2=-2012135647395072713 op3=32/>
38define void @f2([3 x i8*]* %vtable, [3 x i8*]* %vtable2) {
39  %vtablei8 = bitcast [3 x i8*]* %vtable to i8*
40  %p = call i1 @llvm.type.test(i8* %vtablei8, metadata !"foo")
41  call void @llvm.assume(i1 %p)
42  %fptrptr = getelementptr [3 x i8*], [3 x i8*]* %vtable, i32 0, i32 3
43  %fptr = load i8*, i8** %fptrptr
44  %fptr_casted = bitcast i8* %fptr to void (i8*, i32)*
45  call void %fptr_casted(i8* null, i32 undef)
46
47  %vtablei82 = bitcast [3 x i8*]* %vtable2 to i8*
48  %p2 = call i1 @llvm.type.test(i8* %vtablei82, metadata !"bar")
49  call void @llvm.assume(i1 %p2)
50  %fptrptr2 = getelementptr [3 x i8*], [3 x i8*]* %vtable2, i32 0, i32 4
51  %fptr2 = load i8*, i8** %fptrptr2
52  %fptr_casted2 = bitcast i8* %fptr2 to void (i8*, i128)*
53  call void %fptr_casted2(i8* null, i128 0)
54
55  ret void
56}
57
58; CHECK: <TYPE_CHECKED_LOAD_VCALLS op0=6699318081062747564 op1=16/>
59define void @f3(i8* %vtable) {
60  %pair = call {i8*, i1} @llvm.type.checked.load(i8* %vtable, i32 16, metadata !"foo")
61  %fptr = extractvalue {i8*, i1} %pair, 0
62  %fptr_casted = bitcast i8* %fptr to void (i8*, i32)*
63  call void %fptr_casted(i8* null, i32 undef)
64  ret void
65}
66
67; CHECK: <TYPE_TEST_ASSUME_CONST_VCALL op0=6699318081062747564 op1=16 op2=42/>
68; CHECK-NEXT: <TYPE_TEST_ASSUME_CONST_VCALL op0=6699318081062747564 op1=24 op2=43/>
69define void @f4([3 x i8*]* %vtable, [3 x i8*]* %vtable2) {
70  %vtablei8 = bitcast [3 x i8*]* %vtable to i8*
71  %p = call i1 @llvm.type.test(i8* %vtablei8, metadata !"foo")
72  call void @llvm.assume(i1 %p)
73  %fptrptr = getelementptr [3 x i8*], [3 x i8*]* %vtable, i32 0, i32 2
74  %fptr = load i8*, i8** %fptrptr
75  %fptr_casted = bitcast i8* %fptr to void (i8*, i32)*
76  call void %fptr_casted(i8* null, i32 42)
77
78  %vtablei82 = bitcast [3 x i8*]* %vtable2 to i8*
79  %p2 = call i1 @llvm.type.test(i8* %vtablei82, metadata !"foo")
80  call void @llvm.assume(i1 %p2)
81  %fptrptr2 = getelementptr [3 x i8*], [3 x i8*]* %vtable2, i32 0, i32 3
82  %fptr2 = load i8*, i8** %fptrptr2
83  %fptr_casted2 = bitcast i8* %fptr2 to void (i8*, i32)*
84  call void %fptr_casted2(i8* null, i32 43)
85  ret void
86}
87
88; CHECK: <TYPE_CHECKED_LOAD_CONST_VCALL op0=6699318081062747564 op1=16 op2=42/>
89define void @f5(i8* %vtable) {
90  %pair = call {i8*, i1} @llvm.type.checked.load(i8* %vtable, i32 16, metadata !"foo")
91  %fptr = extractvalue {i8*, i1} %pair, 0
92  %fptr_casted = bitcast i8* %fptr to void (i8*, i32)*
93  call void %fptr_casted(i8* null, i32 42)
94  ret void
95}
96
97; CHECK-NOT: <TYPE_CHECKED_LOAD_CONST_VCALL op0=7546896869197086323
98; CHECK: <TYPE_TESTS op0=7546896869197086323/>
99; CHECK-NOT: <TYPE_CHECKED_LOAD_CONST_VCALL op0=7546896869197086323
100define {i8*, i1} @f6(i8* %vtable) {
101  %pair = call {i8*, i1} @llvm.type.checked.load(i8* %vtable, i32 16, metadata !"baz")
102  ret {i8*, i1} %pair
103}
104
105declare i1 @llvm.type.test(i8*, metadata) nounwind readnone
106declare void @llvm.assume(i1)
107declare {i8*, i1} @llvm.type.checked.load(i8*, i32, metadata)
108
109; DIS: ^0 = module: (path: "{{.*}}/test/Bitcode/Output/thinlto-type-vcalls.ll.tmp.o", hash: (0, 0, 0, 0, 0))
110; DIS: ^1 = gv: (name: "llvm.type.test") ; guid = 608142985856744218
111; DIS: ^2 = gv: (name: "f1", summaries: (function: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 8, typeIdInfo: (typeTestAssumeVCalls: (vFuncId: (guid: 6699318081062747564, offset: 16)))))) ; guid = 2072045998141807037
112; DIS: ^3 = gv: (name: "f3", summaries: (function: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 5, typeIdInfo: (typeCheckedLoadVCalls: (vFuncId: (guid: 6699318081062747564, offset: 16)))))) ; guid = 4197650231481825559
113; DIS: ^4 = gv: (name: "llvm.type.checked.load") ; guid = 5568222536364573403
114; DIS: ^5 = gv: (name: "llvm.assume") ; guid = 6385187066495850096
115; DIS: ^6 = gv: (name: "f2", summaries: (function: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 15, typeIdInfo: (typeTestAssumeVCalls: (vFuncId: (guid: 6699318081062747564, offset: 24), vFuncId: (guid: 16434608426314478903, offset: 32)))))) ; guid = 8471399308421654326
116; DIS: ^7 = gv: (name: "f4", summaries: (function: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 15, typeIdInfo: (typeTestAssumeConstVCalls: (vFuncId: (guid: 6699318081062747564, offset: 16), args: (42), vFuncId: (guid: 6699318081062747564, offset: 24), args: (43)))))) ; guid = 10064745020953272174
117; DIS: ^8 = gv: (name: "f5", summaries: (function: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 5, typeIdInfo: (typeCheckedLoadConstVCalls: (vFuncId: (guid: 6699318081062747564, offset: 16), args: (42)))))) ; guid = 11686717102184386164
118; DIS: ^9 = gv: (name: "f6", summaries: (function: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 2, typeIdInfo: (typeTests: (7546896869197086323))))) ; guid = 11834966808443348068
119
120; COMBINED-DIS: ^0 = module: (path: "{{.*}}/test/Bitcode/Output/thinlto-type-vcalls.ll.tmp.o", hash: (0, 0, 0, 0, 0))
121; COMBINED-DIS: ^1 = gv: (guid: 2072045998141807037, summaries: (function: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 8, typeIdInfo: (typeTestAssumeVCalls: (vFuncId: (guid: 6699318081062747564, offset: 16))))))
122; COMBINED-DIS: ^2 = gv: (guid: 4197650231481825559, summaries: (function: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 5, typeIdInfo: (typeCheckedLoadVCalls: (vFuncId: (guid: 6699318081062747564, offset: 16))))))
123; COMBINED-DIS: ^3 = gv: (guid: 8471399308421654326, summaries: (function: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 15, typeIdInfo: (typeTestAssumeVCalls: (vFuncId: (guid: 6699318081062747564, offset: 24), vFuncId: (guid: 16434608426314478903, offset: 32))))))
124; COMBINED-DIS: ^4 = gv: (guid: 10064745020953272174, summaries: (function: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 15, typeIdInfo: (typeTestAssumeConstVCalls: (vFuncId: (guid: 6699318081062747564, offset: 16), args: (42), vFuncId: (guid: 6699318081062747564, offset: 24), args: (43))))))
125; COMBINED-DIS: ^5 = gv: (guid: 11686717102184386164, summaries: (function: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 5, typeIdInfo: (typeCheckedLoadConstVCalls: (vFuncId: (guid: 6699318081062747564, offset: 16), args: (42))))))
126; COMBINED-DIS: ^6 = gv: (guid: 11834966808443348068, summaries: (function: (module: ^0, flags: (linkage: external, notEligibleToImport: 0, live: 0, dsoLocal: 0), insts: 2, typeIdInfo: (typeTests: (7546896869197086323)))))
127