• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3
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
5
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
7
8; RUN: FileCheck --check-prefix=SUMMARY %s < %t
9
10; SUMMARY:      TypeIdMap:
11; SUMMARY-NEXT:   typeid1:
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:
20; SUMMARY-NEXT:       0:
21; SUMMARY-NEXT:         Kind:            BranchFunnel
22; SUMMARY-NEXT:         SingleImplName:  ''
23; SUMMARY-NEXT:         ResByArg:
24; SUMMARY-NEXT:   typeid2:
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:
33; SUMMARY-NEXT:       0:
34; SUMMARY-NEXT:         Kind:            Indir
35; SUMMARY-NEXT:         SingleImplName:  ''
36; SUMMARY-NEXT:         ResByArg:
37; SUMMARY-NEXT:   typeid3:
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:
46; SUMMARY-NEXT:       0:
47; SUMMARY-NEXT:         Kind:            BranchFunnel
48; SUMMARY-NEXT:         SingleImplName:  ''
49; SUMMARY-NEXT:         ResByArg:
50
51target datalayout = "e-p:64:64"
52target triple = "x86_64-unknown-linux-gnu"
53
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
56
57declare i32 @vf1_1(i8* %this, i32 %arg)
58declare i32 @vf1_2(i8* %this, i32 %arg)
59
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
71
72declare i32 @vf2_1(i8* %this, i32 %arg)
73declare i32 @vf2_2(i8* %this, i32 %arg)
74declare i32 @vf2_3(i8* %this, i32 %arg)
75declare i32 @vf2_4(i8* %this, i32 %arg)
76declare i32 @vf2_5(i8* %this, i32 %arg)
77declare i32 @vf2_6(i8* %this, i32 %arg)
78declare i32 @vf2_7(i8* %this, i32 %arg)
79declare i32 @vf2_8(i8* %this, i32 %arg)
80declare i32 @vf2_9(i8* %this, i32 %arg)
81declare i32 @vf2_10(i8* %this, i32 %arg)
82declare i32 @vf2_11(i8* %this, i32 %arg)
83
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
86
87declare i32 @vf3_1(i8* %this, i32 %arg)
88declare i32 @vf3_2(i8* %this, i32 %arg)
89
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
92
93declare i32 @vf4_1(i8* %this, i32 %arg)
94declare i32 @vf4_2(i8* %this, i32 %arg)
95
96
97
98; CHECK-LABEL: define i32 @fn1
99; CHECK-NOT: call void (...) @llvm.icall.branch.funnel
100define 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)
113  ; NORETP: call i32 %
114  ret i32 %result
115}
116
117; CHECK-LABEL: define i32 @fn2
118; CHECK-NOT: call void (...) @llvm.icall.branch.funnel
119define 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)*
128  ; CHECK: call i32 %
129  %result = call i32 %fptr_casted(i8* %obj, i32 1)
130  ret i32 %result
131}
132
133; CHECK-LABEL: define i32 @fn3
134; CHECK-NOT: call void (...) @llvm.icall.branch.funnel
135define 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
145  ; NORETP: call i32 %
146  %result = call i32 %fptr_casted(i8* %obj, i32 1)
147  ret i32 %result
148}
149
150; CHECK-LABEL: define internal void @branch_funnel(i8*
151; CHECK: define hidden void @__typeid_typeid1_0_branch_funnel(i8* nest, ...)
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, ...)
153
154declare i1 @llvm.type.test(i8*, metadata)
155declare void @llvm.assume(i1)
156
157!0 = !{i32 0, !"typeid1"}
158!1 = !{i32 0, !"typeid2"}
159!2 = !{i32 0, !"typeid3"}
160!3 = !{i32 0, !4}
161!4 = distinct !{}
162
163attributes #0 = { "target-features"="+retpoline" }
164