1 ; RUN: opt -S -wholeprogramdevirt %s | FileCheck --check-prefixes=CHECK,RETP %s
2 ; RUN: sed -e 's,+retpoline,-retpoline,g' %s | opt -S -wholeprogramdevirt | FileCheck --check-prefixes=CHECK,NORETP %s
4 ; RUN: opt -wholeprogramdevirt -wholeprogramdevirt-summary-action=export -wholeprogramdevirt-read-summary=%S/Inputs/export.yaml -wholeprogramdevirt-write-summary=%t -S -o - %s | FileCheck --check-prefixes=CHECK,RETP %s
6 ; RUN: opt -wholeprogramdevirt -wholeprogramdevirt-summary-action=export -wholeprogramdevirt-read-summary=%S/Inputs/export.yaml -wholeprogramdevirt-write-summary=%t -O3 -S -o - %s | FileCheck --check-prefixes=CHECK %s
8 ; RUN: FileCheck --check-prefix=SUMMARY %s < %t
11 ; SUMMARY-NEXT: typeid3:
12 ; SUMMARY-NEXT: TTRes:
13 ; SUMMARY-NEXT: Kind: Unsat
14 ; SUMMARY-NEXT: SizeM1BitWidth: 0
15 ; SUMMARY-NEXT: AlignLog2: 0
16 ; SUMMARY-NEXT: SizeM1: 0
17 ; SUMMARY-NEXT: BitMask: 0
18 ; SUMMARY-NEXT: InlineBits: 0
19 ; SUMMARY-NEXT: WPDRes:
21 ; SUMMARY-NEXT: Kind: BranchFunnel
22 ; SUMMARY-NEXT: SingleImplName: ''
23 ; SUMMARY-NEXT: ResByArg:
24 ; SUMMARY-NEXT: typeid1:
25 ; SUMMARY-NEXT: TTRes:
26 ; SUMMARY-NEXT: Kind: Unsat
27 ; SUMMARY-NEXT: SizeM1BitWidth: 0
28 ; SUMMARY-NEXT: AlignLog2: 0
29 ; SUMMARY-NEXT: SizeM1: 0
30 ; SUMMARY-NEXT: BitMask: 0
31 ; SUMMARY-NEXT: InlineBits: 0
32 ; SUMMARY-NEXT: WPDRes:
34 ; SUMMARY-NEXT: Kind: BranchFunnel
35 ; SUMMARY-NEXT: SingleImplName: ''
36 ; SUMMARY-NEXT: ResByArg:
37 ; SUMMARY-NEXT: typeid2:
38 ; SUMMARY-NEXT: TTRes:
39 ; SUMMARY-NEXT: Kind: Unsat
40 ; SUMMARY-NEXT: SizeM1BitWidth: 0
41 ; SUMMARY-NEXT: AlignLog2: 0
42 ; SUMMARY-NEXT: SizeM1: 0
43 ; SUMMARY-NEXT: BitMask: 0
44 ; SUMMARY-NEXT: InlineBits: 0
45 ; SUMMARY-NEXT: WPDRes:
47 ; SUMMARY-NEXT: Kind: Indir
48 ; SUMMARY-NEXT: SingleImplName: ''
49 ; SUMMARY-NEXT: ResByArg:
51 target datalayout = "e-p:64:64"
52 target triple = "x86_64-unknown-linux-gnu"
54 @vt1_1 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf1_1 to i8*)], !type !0
55 @vt1_2 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf1_2 to i8*)], !type !0
57 declare i32 @vf1_1(i8* %this, i32 %arg)
58 declare i32 @vf1_2(i8* %this, i32 %arg)
60 @vt2_1 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf2_1 to i8*)], !type !1
61 @vt2_2 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf2_2 to i8*)], !type !1
62 @vt2_3 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf2_3 to i8*)], !type !1
63 @vt2_4 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf2_4 to i8*)], !type !1
64 @vt2_5 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf2_5 to i8*)], !type !1
65 @vt2_6 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf2_6 to i8*)], !type !1
66 @vt2_7 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf2_7 to i8*)], !type !1
67 @vt2_8 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf2_8 to i8*)], !type !1
68 @vt2_9 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf2_9 to i8*)], !type !1
69 @vt2_10 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf2_10 to i8*)], !type !1
70 @vt2_11 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf2_11 to i8*)], !type !1
72 declare i32 @vf2_1(i8* %this, i32 %arg)
73 declare i32 @vf2_2(i8* %this, i32 %arg)
74 declare i32 @vf2_3(i8* %this, i32 %arg)
75 declare i32 @vf2_4(i8* %this, i32 %arg)
76 declare i32 @vf2_5(i8* %this, i32 %arg)
77 declare i32 @vf2_6(i8* %this, i32 %arg)
78 declare i32 @vf2_7(i8* %this, i32 %arg)
79 declare i32 @vf2_8(i8* %this, i32 %arg)
80 declare i32 @vf2_9(i8* %this, i32 %arg)
81 declare i32 @vf2_10(i8* %this, i32 %arg)
82 declare i32 @vf2_11(i8* %this, i32 %arg)
84 @vt3_1 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf3_1 to i8*)], !type !2
85 @vt3_2 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf3_2 to i8*)], !type !2
87 declare i32 @vf3_1(i8* %this, i32 %arg)
88 declare i32 @vf3_2(i8* %this, i32 %arg)
90 @vt4_1 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf4_1 to i8*)], !type !3
91 @vt4_2 = constant [1 x i8*] [i8* bitcast (i32 (i8*, i32)* @vf4_2 to i8*)], !type !3
93 declare i32 @vf4_1(i8* %this, i32 %arg)
94 declare i32 @vf4_2(i8* %this, i32 %arg)
98 ; CHECK-LABEL: define i32 @fn1
99 ; CHECK-NOT: call void (...) @llvm.icall.branch.funnel
100 define i32 @fn1(i8* %obj) #0 {
101 %vtableptr = bitcast i8* %obj to [1 x i8*]**
102 %vtable = load [1 x i8*]*, [1 x i8*]** %vtableptr
103 %vtablei8 = bitcast [1 x i8*]* %vtable to i8*
104 %p = call i1 @llvm.type.test(i8* %vtablei8, metadata !"typeid1")
105 call void @llvm.assume(i1 %p)
106 %fptrptr = getelementptr [1 x i8*], [1 x i8*]* %vtable, i32 0, i32 0
107 %fptr = load i8*, i8** %fptrptr
108 %fptr_casted = bitcast i8* %fptr to i32 (i8*, i32)*
109 ; RETP: {{.*}} = bitcast {{.*}} to i8*
110 ; RETP: [[VT1:%.*]] = bitcast {{.*}} to i8*
111 ; RETP: call i32 bitcast (void (i8*, ...)* @__typeid_typeid1_0_branch_funnel to i32 (i8*, i8*, i32)*)(i8* nest [[VT1]], i8* %obj, i32 1)
112 %result = call i32 %fptr_casted(i8* %obj, i32 1)
117 ; CHECK-LABEL: define i32 @fn2
118 ; CHECK-NOT: call void (...) @llvm.icall.branch.funnel
119 define i32 @fn2(i8* %obj) #0 {
120 %vtableptr = bitcast i8* %obj to [1 x i8*]**
121 %vtable = load [1 x i8*]*, [1 x i8*]** %vtableptr
122 %vtablei8 = bitcast [1 x i8*]* %vtable to i8*
123 %p = call i1 @llvm.type.test(i8* %vtablei8, metadata !"typeid2")
124 call void @llvm.assume(i1 %p)
125 %fptrptr = getelementptr [1 x i8*], [1 x i8*]* %vtable, i32 0, i32 0
126 %fptr = load i8*, i8** %fptrptr
127 %fptr_casted = bitcast i8* %fptr to i32 (i8*, i32)*
129 %result = call i32 %fptr_casted(i8* %obj, i32 1)
133 ; CHECK-LABEL: define i32 @fn3
134 ; CHECK-NOT: call void (...) @llvm.icall.branch.funnel
135 define i32 @fn3(i8* %obj) #0 {
136 %vtableptr = bitcast i8* %obj to [1 x i8*]**
137 %vtable = load [1 x i8*]*, [1 x i8*]** %vtableptr
138 %vtablei8 = bitcast [1 x i8*]* %vtable to i8*
139 %p = call i1 @llvm.type.test(i8* %vtablei8, metadata !4)
140 call void @llvm.assume(i1 %p)
141 %fptrptr = getelementptr [1 x i8*], [1 x i8*]* %vtable, i32 0, i32 0
142 %fptr = load i8*, i8** %fptrptr
143 %fptr_casted = bitcast i8* %fptr to i32 (i8*, i32)*
144 ; RETP: call i32 bitcast (void (i8*, ...)* @branch_funnel to
146 %result = call i32 %fptr_casted(i8* %obj, i32 1)
150 ; CHECK-LABEL: define internal void @branch_funnel(i8*
151 ; CHECK: define hidden void @__typeid_typeid1_0_branch_funnel(i8* nest %0, ...)
152 ; CHECK-NEXT: musttail call void (...) @llvm.icall.branch.funnel(i8* %0, i8* bitcast ([1 x i8*]* {{(nonnull )?}}@vt1_1 to i8*), i32 (i8*, i32)* {{(nonnull )?}}@vf1_1, i8* bitcast ([1 x i8*]* {{(nonnull )?}}@vt1_2 to i8*), i32 (i8*, i32)* {{(nonnull )?}}@vf1_2, ...)
154 declare i1 @llvm.type.test(i8*, metadata)
155 declare void @llvm.assume(i1)
157 !0 = !{i32 0, !"typeid1"}
158 !1 = !{i32 0, !"typeid2"}
159 !2 = !{i32 0, !"typeid3"}
163 attributes #0 = { "target-features"="+retpoline" }