1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt -S -passes=inline %s | FileCheck %s
3 ; RUN: opt -S -passes='cgscc(inline)' %s | FileCheck %s
4 ; RUN: opt -S -passes='module-inline' %s | FileCheck %s
7 declare void @use.ptr(ptr) willreturn nounwind
10 declare ptr @llvm.ptrmask.p0.i64(ptr, i64)
13 define ptr @callee0123() {
14 ; CHECK-LABEL: define ptr @callee0123() {
15 ; CHECK-NEXT: [[R:%.*]] = call ptr @foo()
16 ; CHECK-NEXT: ret ptr [[R]]
22 define ptr @caller0() {
23 ; CHECK-LABEL: define ptr @caller0() {
24 ; CHECK-NEXT: [[R_I:%.*]] = call dereferenceable(16) ptr @foo()
25 ; CHECK-NEXT: ret ptr [[R_I]]
27 %r = call dereferenceable(16) ptr @callee0123()
31 define ptr @caller1() {
32 ; CHECK-LABEL: define ptr @caller1() {
33 ; CHECK-NEXT: [[R_I:%.*]] = call align 16 ptr @foo()
34 ; CHECK-NEXT: ret ptr [[R_I]]
36 %r = call align(16) ptr @callee0123()
40 define ptr @caller2() {
41 ; CHECK-LABEL: define ptr @caller2() {
42 ; CHECK-NEXT: [[R_I:%.*]] = call noundef ptr @foo()
43 ; CHECK-NEXT: ret ptr [[R_I]]
45 %r = call noundef ptr @callee0123()
49 define ptr @caller3() {
50 ; CHECK-LABEL: define ptr @caller3() {
51 ; CHECK-NEXT: [[R_I:%.*]] = call dereferenceable_or_null(32) ptr @foo()
52 ; CHECK-NEXT: ret ptr [[R_I]]
54 %r = call dereferenceable_or_null(32) ptr @callee0123()
58 define ptr @caller_0123_dornull() {
59 ; CHECK-LABEL: define ptr @caller_0123_dornull() {
60 ; CHECK-NEXT: [[R_I:%.*]] = call noundef align 32 dereferenceable_or_null(16) ptr @foo()
61 ; CHECK-NEXT: ret ptr [[R_I]]
63 %r = call noundef align(32) dereferenceable_or_null(16) ptr @callee0123()
67 define ptr @caller_0123_d() {
68 ; CHECK-LABEL: define ptr @caller_0123_d() {
69 ; CHECK-NEXT: [[R_I:%.*]] = call noundef align 32 dereferenceable(16) ptr @foo()
70 ; CHECK-NEXT: ret ptr [[R_I]]
72 %r = call noundef align(32) dereferenceable(16) ptr @callee0123()
76 define ptr @callee4() {
77 ; CHECK-LABEL: define ptr @callee4() {
78 ; CHECK-NEXT: [[R:%.*]] = call ptr @foo()
79 ; CHECK-NEXT: call void @bar()
80 ; CHECK-NEXT: ret ptr [[R]]
87 define ptr @caller4_fail() {
88 ; CHECK-LABEL: define ptr @caller4_fail() {
89 ; CHECK-NEXT: [[R_I:%.*]] = call ptr @foo()
90 ; CHECK-NEXT: call void @bar()
91 ; CHECK-NEXT: ret ptr [[R_I]]
93 %r = call noundef align(256) ptr @callee4()
97 define ptr @callee5() {
98 ; CHECK-LABEL: define ptr @callee5() {
99 ; CHECK-NEXT: [[R:%.*]] = call align 64 ptr @foo()
100 ; CHECK-NEXT: ret ptr [[R]]
102 %r = call align(64) ptr @foo()
106 define ptr @caller5_fail() {
107 ; CHECK-LABEL: define ptr @caller5_fail() {
108 ; CHECK-NEXT: [[R_I:%.*]] = call noundef align 64 ptr @foo()
109 ; CHECK-NEXT: ret ptr [[R_I]]
111 %r = call noundef align(32) ptr @callee5()
115 define ptr @caller5_okay() {
116 ; CHECK-LABEL: define ptr @caller5_okay() {
117 ; CHECK-NEXT: [[R_I:%.*]] = call noundef align 128 ptr @foo()
118 ; CHECK-NEXT: ret ptr [[R_I]]
120 %r = call noundef align(128) ptr @callee5()
124 define ptr @callee6() {
125 ; CHECK-LABEL: define ptr @callee6() {
126 ; CHECK-NEXT: [[R:%.*]] = call dereferenceable(16) ptr @foo()
127 ; CHECK-NEXT: ret ptr [[R]]
129 %r = call dereferenceable(16) ptr @foo()
133 define ptr @caller6_fail() {
134 ; CHECK-LABEL: define ptr @caller6_fail() {
135 ; CHECK-NEXT: [[R_I:%.*]] = call dereferenceable(16) ptr @foo()
136 ; CHECK-NEXT: ret ptr [[R_I]]
138 %r = call dereferenceable(8) ptr @callee6()
142 define ptr @caller6_okay() {
143 ; CHECK-LABEL: define ptr @caller6_okay() {
144 ; CHECK-NEXT: [[R_I:%.*]] = call dereferenceable(32) ptr @foo()
145 ; CHECK-NEXT: ret ptr [[R_I]]
147 %r = call dereferenceable(32) ptr @callee6()
151 define ptr @callee7() {
152 ; CHECK-LABEL: define ptr @callee7() {
153 ; CHECK-NEXT: [[R:%.*]] = call dereferenceable_or_null(16) ptr @foo()
154 ; CHECK-NEXT: ret ptr [[R]]
156 %r = call dereferenceable_or_null(16) ptr @foo()
160 define ptr @caller7_fail() {
161 ; CHECK-LABEL: define ptr @caller7_fail() {
162 ; CHECK-NEXT: [[R_I:%.*]] = call dereferenceable_or_null(16) ptr @foo()
163 ; CHECK-NEXT: ret ptr [[R_I]]
165 %r = call dereferenceable_or_null(8) ptr @callee7()
169 define ptr @caller7_okay() {
170 ; CHECK-LABEL: define ptr @caller7_okay() {
171 ; CHECK-NEXT: [[R_I:%.*]] = call dereferenceable_or_null(32) ptr @foo()
172 ; CHECK-NEXT: ret ptr [[R_I]]
174 %r = call dereferenceable_or_null(32) ptr @callee7()
178 define ptr @callee8() {
179 ; CHECK-LABEL: define ptr @callee8() {
180 ; CHECK-NEXT: [[R:%.*]] = call ptr @foo()
181 ; CHECK-NEXT: ret ptr [[R]]
187 define ptr @caller8_okay_use_after_poison_anyways() {
188 ; CHECK-LABEL: define ptr @caller8_okay_use_after_poison_anyways() {
189 ; CHECK-NEXT: [[R_I:%.*]] = call nonnull ptr @foo()
190 ; CHECK-NEXT: call void @use.ptr(ptr [[R_I]])
191 ; CHECK-NEXT: ret ptr [[R_I]]
193 %r = call nonnull ptr @callee8()
194 call void @use.ptr(ptr %r)
198 define ptr @callee9() {
199 ; CHECK-LABEL: define ptr @callee9() {
200 ; CHECK-NEXT: [[R:%.*]] = call noundef ptr @foo()
201 ; CHECK-NEXT: ret ptr [[R]]
203 %r = call noundef ptr @foo()
207 define ptr @caller9_fail_creates_ub() {
208 ; CHECK-LABEL: define ptr @caller9_fail_creates_ub() {
209 ; CHECK-NEXT: [[R_I:%.*]] = call noundef ptr @foo()
210 ; CHECK-NEXT: call void @use.ptr(ptr [[R_I]])
211 ; CHECK-NEXT: ret ptr [[R_I]]
213 %r = call nonnull ptr @callee9()
214 call void @use.ptr(ptr %r)
218 define ptr @caller9_okay_is_ub_anyways() {
219 ; CHECK-LABEL: define ptr @caller9_okay_is_ub_anyways() {
220 ; CHECK-NEXT: [[R_I:%.*]] = call noundef nonnull ptr @foo()
221 ; CHECK-NEXT: call void @use.ptr(ptr [[R_I]])
222 ; CHECK-NEXT: ret ptr [[R_I]]
224 %r = call noundef nonnull ptr @callee9()
225 call void @use.ptr(ptr %r)
229 define ptr @callee10() {
230 ; CHECK-LABEL: define ptr @callee10() {
231 ; CHECK-NEXT: [[R:%.*]] = call ptr @foo()
232 ; CHECK-NEXT: call void @use.ptr(ptr [[R]])
233 ; CHECK-NEXT: ret ptr [[R]]
236 call void @use.ptr(ptr %r)
240 define ptr @caller10_fail_maybe_poison() {
241 ; CHECK-LABEL: define ptr @caller10_fail_maybe_poison() {
242 ; CHECK-NEXT: [[R_I:%.*]] = call ptr @foo()
243 ; CHECK-NEXT: call void @use.ptr(ptr [[R_I]])
244 ; CHECK-NEXT: ret ptr [[R_I]]
246 %r = call nonnull ptr @callee10()
250 define ptr @caller10_okay_will_be_ub() {
251 ; CHECK-LABEL: define ptr @caller10_okay_will_be_ub() {
252 ; CHECK-NEXT: [[R_I:%.*]] = call noundef nonnull ptr @foo()
253 ; CHECK-NEXT: call void @use.ptr(ptr [[R_I]])
254 ; CHECK-NEXT: ret ptr [[R_I]]
256 %r = call noundef nonnull ptr @callee10()
260 define noundef ptr @caller10_okay_will_be_ub_todo() {
261 ; CHECK-LABEL: define noundef ptr @caller10_okay_will_be_ub_todo() {
262 ; CHECK-NEXT: [[R_I:%.*]] = call ptr @foo()
263 ; CHECK-NEXT: call void @use.ptr(ptr [[R_I]])
264 ; CHECK-NEXT: ret ptr [[R_I]]
266 %r = call nonnull ptr @callee10()
270 define ptr @callee11() {
271 ; CHECK-LABEL: define ptr @callee11() {
272 ; CHECK-NEXT: [[R:%.*]] = call ptr @foo()
273 ; CHECK-NEXT: [[COND:%.*]] = call i1 @val() #[[ATTR0:[0-9]+]]
274 ; CHECK-NEXT: br i1 [[COND]], label [[TRUE:%.*]], label [[FALSE:%.*]]
276 ; CHECK-NEXT: call void @baz() #[[ATTR0]]
277 ; CHECK-NEXT: ret ptr [[R]]
279 ; CHECK-NEXT: call void @bar() #[[ATTR0]]
280 ; CHECK-NEXT: [[COND2:%.*]] = call i1 @val()
281 ; CHECK-NEXT: ret ptr [[R]]
284 %cond = call i1 @val() nounwind willreturn
285 br i1 %cond, label %True, label %False
287 call void @baz() nounwind willreturn
290 call void @bar() nounwind willreturn
291 %cond2 = call i1 @val()
295 define ptr @caller11_todo() {
296 ; CHECK-LABEL: define ptr @caller11_todo() {
297 ; CHECK-NEXT: [[R_I:%.*]] = call ptr @foo()
298 ; CHECK-NEXT: [[COND_I:%.*]] = call i1 @val() #[[ATTR0]]
299 ; CHECK-NEXT: br i1 [[COND_I]], label [[TRUE_I:%.*]], label [[FALSE_I:%.*]]
301 ; CHECK-NEXT: call void @baz() #[[ATTR0]]
302 ; CHECK-NEXT: br label [[CALLEE11_EXIT:%.*]]
304 ; CHECK-NEXT: call void @bar() #[[ATTR0]]
305 ; CHECK-NEXT: [[COND2_I:%.*]] = call i1 @val()
306 ; CHECK-NEXT: br label [[CALLEE11_EXIT]]
307 ; CHECK: callee11.exit:
308 ; CHECK-NEXT: ret ptr [[R_I]]
310 %r = call nonnull ptr @callee11()
314 define ptr @callee12() {
315 ; CHECK-LABEL: define ptr @callee12() {
316 ; CHECK-NEXT: [[P:%.*]] = call ptr @foo()
317 ; CHECK-NEXT: [[COND:%.*]] = call i1 @val() #[[ATTR0]]
318 ; CHECK-NEXT: [[PP:%.*]] = call ptr @llvm.ptrmask.p0.i64(ptr [[P]], i64 -4)
319 ; CHECK-NEXT: [[R:%.*]] = select i1 [[COND]], ptr [[P]], ptr [[PP]]
320 ; CHECK-NEXT: ret ptr [[R]]
323 %cond = call i1 @val() nounwind willreturn
324 %pp = call ptr @llvm.ptrmask.p0.i64(ptr %p, i64 -4)
325 %r = select i1 %cond, ptr %p, ptr %pp
329 define ptr @caller12_todo() {
330 ; CHECK-LABEL: define ptr @caller12_todo() {
331 ; CHECK-NEXT: [[P_I:%.*]] = call ptr @foo()
332 ; CHECK-NEXT: [[COND_I:%.*]] = call i1 @val() #[[ATTR0]]
333 ; CHECK-NEXT: [[PP_I:%.*]] = call ptr @llvm.ptrmask.p0.i64(ptr [[P_I]], i64 -4)
334 ; CHECK-NEXT: [[R_I:%.*]] = select i1 [[COND_I]], ptr [[P_I]], ptr [[PP_I]]
335 ; CHECK-NEXT: ret ptr [[R_I]]
337 %r = call nonnull ptr @callee12()