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