1 ; RUN: opt -wholeprogramdevirt -wholeprogramdevirt-summary-action=export -wholeprogramdevirt-read-summary=%S/Inputs/export.yaml -wholeprogramdevirt-write-summary=%t -wholeprogramdevirt-branch-funnel-threshold=1 -S -o - %s | not grep @llvm.icall.branch.funnel | count 0
3 ; RUN: opt -wholeprogramdevirt -wholeprogramdevirt-summary-action=export -wholeprogramdevirt-read-summary=%S/Inputs/export.yaml -wholeprogramdevirt-write-summary=%t -wholeprogramdevirt-branch-funnel-threshold=10 -S -o - %s | grep @llvm.icall.branch.funnel | count 4
5 ; RUN: opt -wholeprogramdevirt -wholeprogramdevirt-summary-action=export -wholeprogramdevirt-read-summary=%S/Inputs/export.yaml -wholeprogramdevirt-write-summary=%t -wholeprogramdevirt-branch-funnel-threshold=100 -S -o - %s | grep @llvm.icall.branch.funnel | count 5
7 target datalayout = "e-p:64:64"
8 target triple = "x86_64-unknown-linux-gnu"
10 @vt1_1 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf1_1 to i8*)], !type !0
11 @vt1_2 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf1_2 to i8*)], !type !0
13 declare i32 @vf1_1(i8* %this, i32 %arg)
14 declare i32 @vf1_2(i8* %this, i32 %arg)
16 @vt2_1 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf2_1 to i8*)], !type !1
17 @vt2_2 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf2_2 to i8*)], !type !1
18 @vt2_3 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf2_3 to i8*)], !type !1
19 @vt2_4 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf2_4 to i8*)], !type !1
20 @vt2_5 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf2_5 to i8*)], !type !1
21 @vt2_6 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf2_6 to i8*)], !type !1
22 @vt2_7 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf2_7 to i8*)], !type !1
23 @vt2_8 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf2_8 to i8*)], !type !1
24 @vt2_9 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf2_9 to i8*)], !type !1
25 @vt2_10 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf2_10 to i8*)], !type !1
26 @vt2_11 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf2_11 to i8*)], !type !1
28 declare i32 @vf2_1(i8* %this, i32 %arg)
29 declare i32 @vf2_2(i8* %this, i32 %arg)
30 declare i32 @vf2_3(i8* %this, i32 %arg)
31 declare i32 @vf2_4(i8* %this, i32 %arg)
32 declare i32 @vf2_5(i8* %this, i32 %arg)
33 declare i32 @vf2_6(i8* %this, i32 %arg)
34 declare i32 @vf2_7(i8* %this, i32 %arg)
35 declare i32 @vf2_8(i8* %this, i32 %arg)
36 declare i32 @vf2_9(i8* %this, i32 %arg)
37 declare i32 @vf2_10(i8* %this, i32 %arg)
38 declare i32 @vf2_11(i8* %this, i32 %arg)
40 @vt3_1 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf3_1 to i8*)], !type !2
41 @vt3_2 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf3_2 to i8*)], !type !2
43 declare i32 @vf3_1(i8* %this, i32 %arg)
44 declare i32 @vf3_2(i8* %this, i32 %arg)
46 @vt4_1 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf4_1 to i8*)], !type !3
47 @vt4_2 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf4_2 to i8*)], !type !3
49 declare i32 @vf4_1(i8* %this, i32 %arg)
50 declare i32 @vf4_2(i8* %this, i32 %arg)
52 define i32 @fn1(i8* %obj) #0 {
53 %vtableptr = bitcast i8* %obj to [1 x i8*]**
54 %vtable = load [1 x i8*]*, [1 x i8*]** %vtableptr
55 %vtablei8 = bitcast [1 x i8*]* %vtable to i8*
56 %p = call i1 @llvm.type.test(i8* %vtablei8, metadata !"typeid1")
57 call void @llvm.assume(i1 %p)
58 %fptrptr = getelementptr [1 x i8*], [1 x i8*]* %vtable, i32 0, i32 0
59 %fptr = load i8*, i8** %fptrptr
60 %fptr_casted = bitcast i8* %fptr to i32 (i8*, i32)*
61 %result = call i32 %fptr_casted(i8* %obj, i32 1)
65 define i32 @fn2(i8* %obj) #0 {
66 %vtableptr = bitcast i8* %obj to [1 x i8*]**
67 %vtable = load [1 x i8*]*, [1 x i8*]** %vtableptr
68 %vtablei8 = bitcast [1 x i8*]* %vtable to i8*
69 %p = call i1 @llvm.type.test(i8* %vtablei8, metadata !"typeid2")
70 call void @llvm.assume(i1 %p)
71 %fptrptr = getelementptr [1 x i8*], [1 x i8*]* %vtable, i32 0, i32 0
72 %fptr = load i8*, i8** %fptrptr
73 %fptr_casted = bitcast i8* %fptr to i32 (i8*, i32)*
74 %result = call i32 %fptr_casted(i8* %obj, i32 1)
78 define i32 @fn3(i8* %obj) #0 {
79 %vtableptr = bitcast i8* %obj to [1 x i8*]**
80 %vtable = load [1 x i8*]*, [1 x i8*]** %vtableptr
81 %vtablei8 = bitcast [1 x i8*]* %vtable to i8*
82 %p = call i1 @llvm.type.test(i8* %vtablei8, metadata !4)
83 call void @llvm.assume(i1 %p)
84 %fptrptr = getelementptr [1 x i8*], [1 x i8*]* %vtable, i32 0, i32 0
85 %fptr = load i8*, i8** %fptrptr
86 %fptr_casted = bitcast i8* %fptr to i32 (i8*, i32)*
87 %result = call i32 %fptr_casted(i8* %obj, i32 1)
91 declare i1 @llvm.type.test(i8*, metadata)
92 declare void @llvm.assume(i1)
94 !0 = !{i32 0, !"typeid1"}
95 !1 = !{i32 0, !"typeid2"}
96 !2 = !{i32 0, !"typeid3"}
100 attributes #0 = { "target-features"="+retpoline" }