1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
2 ; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
3 ; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC
4 ; FIXME: Figure out why we need 16 iterations here.
6 declare void @deref_phi_user(ptr %a);
9 ; take mininimum of return values
12 ; CHECK: @g = global i64 0
14 define ptr @test1(ptr dereferenceable(4) %0, ptr dereferenceable(8) %1, i1 zeroext %2) local_unnamed_addr {
15 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
16 ; CHECK-LABEL: define {{[^@]+}}@test1
17 ; CHECK-SAME: (ptr nofree noundef nonnull readnone dereferenceable(4) "no-capture-maybe-returned" [[TMP0:%.*]], ptr nofree noundef nonnull readnone dereferenceable(8) "no-capture-maybe-returned" [[TMP1:%.*]], i1 zeroext [[TMP2:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
18 ; CHECK-NEXT: [[TMP4:%.*]] = select i1 [[TMP2]], ptr [[TMP0]], ptr [[TMP1]]
19 ; CHECK-NEXT: ret ptr [[TMP4]]
21 %4 = select i1 %2, ptr %0, ptr %1
26 define ptr @test2(ptr dereferenceable_or_null(4) %0, ptr dereferenceable(8) %1, i1 zeroext %2) local_unnamed_addr {
27 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
28 ; CHECK-LABEL: define {{[^@]+}}@test2
29 ; CHECK-SAME: (ptr nofree noundef readnone dereferenceable_or_null(4) "no-capture-maybe-returned" [[TMP0:%.*]], ptr nofree noundef nonnull readnone dereferenceable(8) "no-capture-maybe-returned" [[TMP1:%.*]], i1 zeroext [[TMP2:%.*]]) local_unnamed_addr #[[ATTR0]] {
30 ; CHECK-NEXT: [[TMP4:%.*]] = select i1 [[TMP2]], ptr [[TMP0]], ptr [[TMP1]]
31 ; CHECK-NEXT: ret ptr [[TMP4]]
33 %4 = select i1 %2, ptr %0, ptr %1
39 define ptr @test3_1(ptr dereferenceable(8) %0) local_unnamed_addr {
40 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
41 ; CHECK-LABEL: define {{[^@]+}}@test3_1
42 ; CHECK-SAME: (ptr nofree noundef nonnull readnone dereferenceable(8) "no-capture-maybe-returned" [[TMP0:%.*]]) local_unnamed_addr #[[ATTR0]] {
43 ; CHECK-NEXT: [[RET:%.*]] = getelementptr inbounds i32, ptr [[TMP0]], i64 1
44 ; CHECK-NEXT: ret ptr [[RET]]
46 %ret = getelementptr inbounds i32, ptr %0, i64 1
50 define ptr @test3_2(ptr dereferenceable_or_null(32) %0) local_unnamed_addr {
51 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
52 ; CHECK-LABEL: define {{[^@]+}}@test3_2
53 ; CHECK-SAME: (ptr nofree noundef readnone dereferenceable_or_null(32) "no-capture-maybe-returned" [[TMP0:%.*]]) local_unnamed_addr #[[ATTR0]] {
54 ; CHECK-NEXT: [[RET:%.*]] = getelementptr inbounds i32, ptr [[TMP0]], i64 4
55 ; CHECK-NEXT: ret ptr [[RET]]
57 %ret = getelementptr inbounds i32, ptr %0, i64 4
61 define ptr @test3_3(ptr dereferenceable(8) %0, ptr dereferenceable(16) %1, i1 %2) local_unnamed_addr {
62 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
63 ; CHECK-LABEL: define {{[^@]+}}@test3_3
64 ; CHECK-SAME: (ptr nofree noundef nonnull readnone dereferenceable(8) "no-capture-maybe-returned" [[TMP0:%.*]], ptr nofree noundef nonnull readnone dereferenceable(16) "no-capture-maybe-returned" [[TMP1:%.*]], i1 [[TMP2:%.*]]) local_unnamed_addr #[[ATTR0]] {
65 ; CHECK-NEXT: [[RET1:%.*]] = getelementptr inbounds i32, ptr [[TMP0]], i64 1
66 ; CHECK-NEXT: [[RET2:%.*]] = getelementptr inbounds i32, ptr [[TMP1]], i64 2
67 ; CHECK-NEXT: [[RET:%.*]] = select i1 [[TMP2]], ptr [[RET1]], ptr [[RET2]]
68 ; CHECK-NEXT: ret ptr [[RET]]
70 %ret1 = getelementptr inbounds i32, ptr %0, i64 1
71 %ret2 = getelementptr inbounds i32, ptr %1, i64 2
72 %ret = select i1 %2, ptr %ret1, ptr %ret2
77 ; Better than known in IR.
79 define dereferenceable(4) ptr @test4(ptr dereferenceable(8) %0) local_unnamed_addr {
80 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
81 ; CHECK-LABEL: define {{[^@]+}}@test4
82 ; CHECK-SAME: (ptr nofree noundef nonnull readnone returned dereferenceable(8) "no-capture-maybe-returned" [[TMP0:%.*]]) local_unnamed_addr #[[ATTR0]] {
83 ; CHECK-NEXT: ret ptr [[TMP0]]
89 ; loop in which dereferenceabily "grows"
90 define void @deref_phi_growing(ptr dereferenceable(4000) %a) {
91 ; CHECK-LABEL: define {{[^@]+}}@deref_phi_growing
92 ; CHECK-SAME: (ptr noundef nonnull dereferenceable(4000) [[A:%.*]]) {
94 ; CHECK-NEXT: br label [[FOR_COND:%.*]]
96 ; CHECK-NEXT: [[I_0:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], [[FOR_INC:%.*]] ]
97 ; CHECK-NEXT: [[A_ADDR_0:%.*]] = phi ptr [ [[A]], [[ENTRY]] ], [ [[INCDEC_PTR:%.*]], [[FOR_INC]] ]
98 ; CHECK-NEXT: call void @deref_phi_user(ptr nonnull [[A_ADDR_0]])
99 ; CHECK-NEXT: [[VAL:%.*]] = load i32, ptr [[A_ADDR_0]], align 4
100 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[I_0]], [[VAL]]
101 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY:%.*]], label [[FOR_COND_CLEANUP:%.*]]
102 ; CHECK: for.cond.cleanup:
103 ; CHECK-NEXT: br label [[FOR_END:%.*]]
105 ; CHECK-NEXT: br label [[FOR_INC]]
107 ; CHECK-NEXT: [[INCDEC_PTR]] = getelementptr inbounds i32, ptr [[A_ADDR_0]], i64 -1
108 ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_0]], 1
109 ; CHECK-NEXT: br label [[FOR_COND]]
111 ; CHECK-NEXT: ret void
116 for.cond: ; preds = %for.inc, %entry
117 %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
118 %a.addr.0 = phi ptr [ %a, %entry ], [ %incdec.ptr, %for.inc ]
119 call void @deref_phi_user(ptr %a.addr.0)
120 %val = load i32, ptr %a.addr.0, align 4
121 %cmp = icmp slt i32 %i.0, %val
122 br i1 %cmp, label %for.body, label %for.cond.cleanup
124 for.cond.cleanup: ; preds = %for.cond
127 for.body: ; preds = %for.cond
130 for.inc: ; preds = %for.body
131 %incdec.ptr = getelementptr inbounds i32, ptr %a.addr.0, i64 -1
132 %inc = add nuw nsw i32 %i.0, 1
135 for.end: ; preds = %for.cond.cleanup
140 ; loop in which dereferenceabily "shrinks"
141 define void @deref_phi_shrinking(ptr dereferenceable(4000) %a) {
142 ; CHECK-LABEL: define {{[^@]+}}@deref_phi_shrinking
143 ; CHECK-SAME: (ptr noundef nonnull dereferenceable(4000) [[A:%.*]]) {
145 ; CHECK-NEXT: br label [[FOR_COND:%.*]]
147 ; CHECK-NEXT: [[I_0:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], [[FOR_INC:%.*]] ]
148 ; CHECK-NEXT: [[A_ADDR_0:%.*]] = phi ptr [ [[A]], [[ENTRY]] ], [ [[INCDEC_PTR:%.*]], [[FOR_INC]] ]
149 ; CHECK-NEXT: call void @deref_phi_user(ptr nonnull [[A_ADDR_0]])
150 ; CHECK-NEXT: [[VAL:%.*]] = load i32, ptr [[A_ADDR_0]], align 4
151 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i32 [[I_0]], [[VAL]]
152 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY:%.*]], label [[FOR_COND_CLEANUP:%.*]]
153 ; CHECK: for.cond.cleanup:
154 ; CHECK-NEXT: br label [[FOR_END:%.*]]
156 ; CHECK-NEXT: br label [[FOR_INC]]
158 ; CHECK-NEXT: [[INCDEC_PTR]] = getelementptr inbounds i32, ptr [[A_ADDR_0]], i64 1
159 ; CHECK-NEXT: [[INC]] = add nuw nsw i32 [[I_0]], 1
160 ; CHECK-NEXT: br label [[FOR_COND]]
162 ; CHECK-NEXT: ret void
167 for.cond: ; preds = %for.inc, %entry
168 %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
169 %a.addr.0 = phi ptr [ %a, %entry ], [ %incdec.ptr, %for.inc ]
170 call void @deref_phi_user(ptr %a.addr.0)
171 %val = load i32, ptr %a.addr.0, align 4
172 %cmp = icmp slt i32 %i.0, %val
173 br i1 %cmp, label %for.body, label %for.cond.cleanup
175 for.cond.cleanup: ; preds = %for.cond
178 for.body: ; preds = %for.cond
181 for.inc: ; preds = %for.body
182 %incdec.ptr = getelementptr inbounds i32, ptr %a.addr.0, i64 1
183 %inc = add nuw nsw i32 %i.0, 1
186 for.end: ; preds = %for.cond.cleanup
191 ; share known infomation in must-be-executed-context
192 declare ptr @unkown_ptr() willreturn nounwind
193 declare i32 @unkown_f(ptr) willreturn nounwind
194 define ptr @f7_0(ptr %ptr) {
195 ; CHECK: Function Attrs: mustprogress nounwind willreturn
196 ; CHECK-LABEL: define {{[^@]+}}@f7_0
197 ; CHECK-SAME: (ptr noundef nonnull returned dereferenceable(8) [[PTR:%.*]]) #[[ATTR2:[0-9]+]] {
198 ; CHECK-NEXT: [[T:%.*]] = tail call i32 @unkown_f(ptr noundef nonnull dereferenceable(8) [[PTR]]) #[[ATTR1:[0-9]+]]
199 ; CHECK-NEXT: ret ptr [[PTR]]
201 %T = tail call i32 @unkown_f(ptr dereferenceable(8) %ptr)
205 define void @f7_1(ptr %ptr, i1 %cnd) {
206 ; CHECK: Function Attrs: mustprogress nounwind willreturn
207 ; CHECK-LABEL: define {{[^@]+}}@f7_1
208 ; CHECK-SAME: (ptr noundef nonnull align 4 dereferenceable(4) [[PTR:%.*]], i1 noundef [[CND:%.*]]) #[[ATTR2]] {
209 ; CHECK-NEXT: [[A:%.*]] = tail call i32 @unkown_f(ptr noundef nonnull align 4 dereferenceable(4) [[PTR]]) #[[ATTR1]]
210 ; CHECK-NEXT: [[PTR_0:%.*]] = load i32, ptr [[PTR]], align 4
211 ; CHECK-NEXT: [[B:%.*]] = tail call i32 @unkown_f(ptr noundef nonnull align 4 dereferenceable(4) [[PTR]]) #[[ATTR1]]
212 ; CHECK-NEXT: br i1 [[CND]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
214 ; CHECK-NEXT: [[C:%.*]] = tail call i32 @unkown_f(ptr noundef nonnull align 4 dereferenceable(8) [[PTR]]) #[[ATTR1]]
215 ; CHECK-NEXT: [[D:%.*]] = tail call i32 @unkown_f(ptr noundef nonnull align 4 dereferenceable(8) [[PTR]]) #[[ATTR1]]
216 ; CHECK-NEXT: [[E:%.*]] = tail call i32 @unkown_f(ptr noundef nonnull align 4 dereferenceable(8) [[PTR]]) #[[ATTR1]]
217 ; CHECK-NEXT: ret void
219 ; CHECK-NEXT: ret void
221 %A = tail call i32 @unkown_f(ptr %ptr)
222 %ptr.0 = load i32, ptr %ptr
224 ; FIXME: this should be %B = tail call i32 @unkown_f(ptr nonnull dereferenceable(4) %ptr)
225 %B = tail call i32 @unkown_f(ptr dereferenceable(1) %ptr)
226 br i1%cnd, label %if.true, label %if.false
228 %C = tail call i32 @unkown_f(ptr %ptr)
229 %D = tail call i32 @unkown_f(ptr dereferenceable(8) %ptr)
230 %E = tail call i32 @unkown_f(ptr %ptr)
236 define void @f7_2(i1 %cnd) {
237 ; CHECK: Function Attrs: mustprogress nounwind willreturn
238 ; CHECK-LABEL: define {{[^@]+}}@f7_2
239 ; CHECK-SAME: (i1 noundef [[CND:%.*]]) #[[ATTR2]] {
240 ; CHECK-NEXT: [[PTR:%.*]] = tail call nonnull align 4 dereferenceable(4) ptr @unkown_ptr() #[[ATTR1]]
241 ; CHECK-NEXT: [[A:%.*]] = tail call i32 @unkown_f(ptr noundef nonnull align 4 dereferenceable(4) [[PTR]]) #[[ATTR1]]
242 ; CHECK-NEXT: [[ARG_A_0:%.*]] = load i32, ptr [[PTR]], align 4
243 ; CHECK-NEXT: [[B:%.*]] = tail call i32 @unkown_f(ptr noundef nonnull align 4 dereferenceable(4) [[PTR]]) #[[ATTR1]]
244 ; CHECK-NEXT: br i1 [[CND]], label [[IF_TRUE:%.*]], label [[IF_FALSE:%.*]]
246 ; CHECK-NEXT: [[C:%.*]] = tail call i32 @unkown_f(ptr noundef nonnull align 4 dereferenceable(8) [[PTR]]) #[[ATTR1]]
247 ; CHECK-NEXT: [[D:%.*]] = tail call i32 @unkown_f(ptr noundef nonnull align 4 dereferenceable(8) [[PTR]]) #[[ATTR1]]
248 ; CHECK-NEXT: [[E:%.*]] = tail call i32 @unkown_f(ptr noundef nonnull align 4 dereferenceable(8) [[PTR]]) #[[ATTR1]]
249 ; CHECK-NEXT: ret void
251 ; CHECK-NEXT: ret void
253 %ptr = tail call ptr @unkown_ptr()
254 %A = tail call i32 @unkown_f(ptr %ptr)
255 %arg_a.0 = load i32, ptr %ptr
257 %B = tail call i32 @unkown_f(ptr dereferenceable(1) %ptr)
258 br i1%cnd, label %if.true, label %if.false
260 %C = tail call i32 @unkown_f(ptr %ptr)
261 %D = tail call i32 @unkown_f(ptr dereferenceable(8) %ptr)
262 %E = tail call i32 @unkown_f(ptr %ptr)
269 ; CHECK: Function Attrs: mustprogress nounwind willreturn
270 ; CHECK-LABEL: define {{[^@]+}}@f7_3
271 ; CHECK-SAME: () #[[ATTR2]] {
272 ; CHECK-NEXT: [[PTR:%.*]] = tail call noundef nonnull align 16 dereferenceable(4) ptr @unkown_ptr() #[[ATTR1]]
273 ; CHECK-NEXT: store i32 10, ptr [[PTR]], align 16
274 ; CHECK-NEXT: ret ptr [[PTR]]
276 %ptr = tail call ptr @unkown_ptr()
277 store i32 10, ptr %ptr, align 16
281 ; FIXME: This should have a return dereferenceable(8) but we need to make sure it will work in loops as well.
282 define ptr @test_for_minus_index(ptr %p) {
283 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write)
284 ; CHECK-LABEL: define {{[^@]+}}@test_for_minus_index
285 ; CHECK-SAME: (ptr nofree nonnull writeonly align 4 "no-capture-maybe-returned" [[P:%.*]]) #[[ATTR3:[0-9]+]] {
286 ; CHECK-NEXT: [[Q:%.*]] = getelementptr inbounds i32, ptr [[P]], i32 -2
287 ; CHECK-NEXT: store i32 1, ptr [[Q]], align 4
288 ; CHECK-NEXT: ret ptr [[Q]]
290 %q = getelementptr inbounds i32, ptr %p, i32 -2
295 define void @deref_or_null_and_nonnull(ptr dereferenceable_or_null(100) %0) {
296 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write)
297 ; CHECK-LABEL: define {{[^@]+}}@deref_or_null_and_nonnull
298 ; CHECK-SAME: (ptr nocapture nofree noundef nonnull writeonly align 4 dereferenceable(100) [[TMP0:%.*]]) #[[ATTR3]] {
299 ; CHECK-NEXT: store i32 1, ptr [[TMP0]], align 4
300 ; CHECK-NEXT: ret void
307 ; Use Constant range in deereferenceable
308 ; void g(int *p, long long int *range){
309 ; int r = *range ; // [10, 99]
310 ; fill_range(p, *range);
313 ; FIXME: %ptr should be dereferenceable(31)
314 define void @test8(ptr %ptr) #0 {
315 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write)
316 ; CHECK-LABEL: define {{[^@]+}}@test8
317 ; CHECK-SAME: (ptr nocapture nofree nonnull writeonly dereferenceable(21) [[PTR:%.*]]) #[[ATTR3]] {
318 ; CHECK-NEXT: br label [[TMP1:%.*]]
320 ; CHECK-NEXT: [[I_0:%.*]] = phi i32 [ 20, [[TMP0:%.*]] ], [ [[TMP4:%.*]], [[TMP5:%.*]] ]
321 ; CHECK-NEXT: [[TMP2:%.*]] = sext i32 [[I_0]] to i64
322 ; CHECK-NEXT: [[TMP3:%.*]] = getelementptr inbounds i8, ptr [[PTR]], i64 [[TMP2]]
323 ; CHECK-NEXT: store i8 32, ptr [[TMP3]], align 1
324 ; CHECK-NEXT: [[TMP4]] = add nsw i32 [[I_0]], 1
325 ; CHECK-NEXT: br label [[TMP5]]
327 ; CHECK-NEXT: [[TMP6:%.*]] = icmp slt i32 [[TMP4]], 30
328 ; CHECK-NEXT: br i1 [[TMP6]], label [[TMP1]], label [[TMP7:%.*]]
330 ; CHECK-NEXT: ret void
334 %i.0 = phi i32 [ 20, %0 ], [ %4, %5 ]
335 %2 = sext i32 %i.0 to i64
336 %3 = getelementptr inbounds i8, ptr %ptr, i64 %2
337 store i8 32, ptr %3, align 1
338 %4 = add nsw i32 %i.0, 1
341 %6 = icmp slt i32 %4, 30
342 br i1 %6, label %1, label %7
348 ; 8.2 (negative case)
349 define void @test8_neg(i32 %i, ptr %ptr) #0 {
350 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write)
351 ; CHECK-LABEL: define {{[^@]+}}@test8_neg
352 ; CHECK-SAME: (i32 [[I:%.*]], ptr nocapture nofree nonnull writeonly [[PTR:%.*]]) #[[ATTR3]] {
353 ; CHECK-NEXT: [[TMP1:%.*]] = sext i32 [[I]] to i64
354 ; CHECK-NEXT: [[TMP2:%.*]] = getelementptr inbounds i8, ptr [[PTR]], i64 [[TMP1]]
355 ; CHECK-NEXT: store i8 65, ptr [[TMP2]], align 1
356 ; CHECK-NEXT: ret void
358 %1 = sext i32 %i to i64
359 %2 = getelementptr inbounds i8, ptr %ptr, i64 %1
360 store i8 65, ptr %2, align 1
364 ; void fill_range(int* p, long long int start){
365 ; for(long long int i = start;i<start+10;i++){
366 ; // If p[i] is inbounds, p is dereferenceable(40) at least.
371 ; NOTE: %p should not be dereferenceable
372 define internal void @fill_range_not_inbounds(ptr %p, i64 %start){
373 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write)
374 ; CHECK-LABEL: define {{[^@]+}}@fill_range_not_inbounds
375 ; CHECK-SAME: (ptr nocapture nofree writeonly [[P:%.*]], i64 [[START:%.*]]) #[[ATTR3]] {
377 ; CHECK-NEXT: [[TMP0:%.*]] = add nsw i64 [[START]], 9
378 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
379 ; CHECK: for.cond.cleanup:
380 ; CHECK-NEXT: ret void
382 ; CHECK-NEXT: [[I_06:%.*]] = phi i64 [ [[START]], [[ENTRY:%.*]] ], [ [[INC:%.*]], [[FOR_BODY]] ]
383 ; CHECK-NEXT: [[CONV:%.*]] = trunc i64 [[I_06]] to i32
384 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr i32, ptr [[P]], i64 [[I_06]]
385 ; CHECK-NEXT: store i32 [[CONV]], ptr [[ARRAYIDX]], align 4
386 ; CHECK-NEXT: [[INC]] = add nsw i64 [[I_06]], 1
387 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i64 [[I_06]], [[TMP0]]
388 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_COND_CLEANUP:%.*]]
391 %0 = add nsw i64 %start, 9
394 for.cond.cleanup: ; preds = %for.body
397 for.body: ; preds = %entry, %for.body
398 %i.06 = phi i64 [ %start, %entry ], [ %inc, %for.body ]
399 %conv = trunc i64 %i.06 to i32
400 %arrayidx = getelementptr i32, ptr %p, i64 %i.06
401 store i32 %conv, ptr %arrayidx, align 4
402 %inc = add nsw i64 %i.06, 1
403 %cmp = icmp slt i64 %i.06, %0
404 br i1 %cmp, label %for.body, label %for.cond.cleanup
407 ; FIXME: %p should be dereferenceable(40)
408 define internal void @fill_range_inbounds(ptr %p, i64 %start){
409 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write)
410 ; CHECK-LABEL: define {{[^@]+}}@fill_range_inbounds
411 ; CHECK-SAME: (ptr nocapture nofree writeonly [[P:%.*]], i64 [[START:%.*]]) #[[ATTR3]] {
413 ; CHECK-NEXT: [[TMP0:%.*]] = add nsw i64 [[START]], 9
414 ; CHECK-NEXT: br label [[FOR_BODY:%.*]]
415 ; CHECK: for.cond.cleanup:
416 ; CHECK-NEXT: ret void
418 ; CHECK-NEXT: [[I_06:%.*]] = phi i64 [ [[START]], [[ENTRY:%.*]] ], [ [[INC:%.*]], [[FOR_BODY]] ]
419 ; CHECK-NEXT: [[CONV:%.*]] = trunc i64 [[I_06]] to i32
420 ; CHECK-NEXT: [[ARRAYIDX:%.*]] = getelementptr inbounds i32, ptr [[P]], i64 [[I_06]]
421 ; CHECK-NEXT: store i32 [[CONV]], ptr [[ARRAYIDX]], align 4
422 ; CHECK-NEXT: [[INC]] = add nsw i64 [[I_06]], 1
423 ; CHECK-NEXT: [[CMP:%.*]] = icmp slt i64 [[I_06]], [[TMP0]]
424 ; CHECK-NEXT: br i1 [[CMP]], label [[FOR_BODY]], label [[FOR_COND_CLEANUP:%.*]]
427 %0 = add nsw i64 %start, 9
430 for.cond.cleanup: ; preds = %for.body
433 for.body: ; preds = %entry, %for.body
434 %i.06 = phi i64 [ %start, %entry ], [ %inc, %for.body ]
435 %conv = trunc i64 %i.06 to i32
436 %arrayidx = getelementptr inbounds i32, ptr %p, i64 %i.06
437 store i32 %conv, ptr %arrayidx, align 4
438 %inc = add nsw i64 %i.06, 1
439 %cmp = icmp slt i64 %i.06, %0
440 br i1 %cmp, label %for.body, label %for.cond.cleanup
443 define void @call_fill_range(ptr nocapture %p, ptr nocapture readonly %range) {
444 ; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite)
445 ; TUNIT-LABEL: define {{[^@]+}}@call_fill_range
446 ; TUNIT-SAME: (ptr nocapture nofree writeonly [[P:%.*]], ptr nocapture nofree noundef nonnull readonly align 8 dereferenceable(8) [[RANGE:%.*]]) #[[ATTR4:[0-9]+]] {
448 ; TUNIT-NEXT: [[TMP0:%.*]] = load i64, ptr [[RANGE]], align 8, !range [[RNG0:![0-9]+]]
449 ; TUNIT-NEXT: tail call void @fill_range_inbounds(ptr nocapture nofree writeonly [[P]], i64 [[TMP0]]) #[[ATTR7:[0-9]+]]
450 ; TUNIT-NEXT: tail call void @fill_range_not_inbounds(ptr nocapture nofree writeonly [[P]], i64 [[TMP0]]) #[[ATTR7]]
451 ; TUNIT-NEXT: ret void
453 ; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(argmem: readwrite)
454 ; CGSCC-LABEL: define {{[^@]+}}@call_fill_range
455 ; CGSCC-SAME: (ptr nocapture nofree writeonly [[P:%.*]], ptr nocapture nofree noundef nonnull readonly align 8 dereferenceable(8) [[RANGE:%.*]]) #[[ATTR4:[0-9]+]] {
457 ; CGSCC-NEXT: [[TMP0:%.*]] = load i64, ptr [[RANGE]], align 8, !range [[RNG0:![0-9]+]]
458 ; CGSCC-NEXT: tail call void @fill_range_inbounds(ptr nocapture nofree writeonly [[P]], i64 [[TMP0]]) #[[ATTR7:[0-9]+]]
459 ; CGSCC-NEXT: tail call void @fill_range_not_inbounds(ptr nocapture nofree writeonly [[P]], i64 [[TMP0]]) #[[ATTR7]]
460 ; CGSCC-NEXT: ret void
463 %0 = load i64, ptr %range, align 8, !range !0
464 tail call void @fill_range_inbounds(ptr %p, i64 %0)
465 tail call void @fill_range_not_inbounds(ptr %p, i64 %0)
469 declare void @use0() willreturn nounwind
470 declare void @use1(ptr) willreturn nounwind
471 declare void @use2(ptr, ptr) willreturn nounwind
472 declare void @use3(ptr, ptr, ptr) willreturn nounwind
476 ; fun2(dereferenceable(8) %a, dereferenceable(8) %b)
478 ; fun2(dereferenceable(4) %a, %b)
479 ; We can say that %a is dereferenceable(4) but %b is not.
480 define void @simple-path(ptr %a, ptr %b, i8 %c) {
481 ; CHECK: Function Attrs: mustprogress nounwind willreturn
482 ; CHECK-LABEL: define {{[^@]+}}@simple-path
483 ; CHECK-SAME: (ptr nonnull dereferenceable(4) [[A:%.*]], ptr [[B:%.*]], i8 [[C:%.*]]) #[[ATTR2]] {
484 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[C]], 0
485 ; CHECK-NEXT: br i1 [[CMP]], label [[IF_THEN:%.*]], label [[IF_ELSE:%.*]]
487 ; CHECK-NEXT: tail call void @use2(ptr nonnull dereferenceable(8) [[A]], ptr nonnull dereferenceable(8) [[B]]) #[[ATTR1]]
488 ; CHECK-NEXT: ret void
490 ; CHECK-NEXT: tail call void @use2(ptr nonnull dereferenceable(4) [[A]], ptr [[B]]) #[[ATTR1]]
491 ; CHECK-NEXT: ret void
493 %cmp = icmp eq i8 %c, 0
494 br i1 %cmp, label %if.then, label %if.else
496 tail call void @use2(ptr dereferenceable(8) %a, ptr dereferenceable(8) %b)
499 tail call void @use2(ptr dereferenceable(4) %a, ptr %b)
505 ; fun1(dereferenceable(4) %a)
507 ; ... (willreturn & nounwind)
508 ; fun1(dereferenceable(12) %a)
510 ; ... (willreturn & nounwind)
511 ; fun1(dereferenceable(16) %a)
512 ; fun1(dereferenceable(8) %a)
514 ; %a is dereferenceable(12)
515 define void @complex-path(ptr %a, ptr %b, i8 %c) {
516 ; CHECK: Function Attrs: mustprogress nounwind willreturn
517 ; CHECK-LABEL: define {{[^@]+}}@complex-path
518 ; CHECK-SAME: (ptr noundef nonnull dereferenceable(12) [[A:%.*]], ptr nocapture nofree readnone [[B:%.*]], i8 [[C:%.*]]) #[[ATTR2]] {
519 ; CHECK-NEXT: [[CMP:%.*]] = icmp eq i8 [[C]], 0
520 ; CHECK-NEXT: tail call void @use1(ptr noundef nonnull dereferenceable(12) [[A]]) #[[ATTR1]]
521 ; CHECK-NEXT: br i1 [[CMP]], label [[CONT_THEN:%.*]], label [[CONT_ELSE:%.*]]
523 ; CHECK-NEXT: tail call void @use1(ptr noundef nonnull dereferenceable(12) [[A]]) #[[ATTR1]]
524 ; CHECK-NEXT: br label [[CONT2:%.*]]
526 ; CHECK-NEXT: tail call void @use1(ptr noundef nonnull dereferenceable(16) [[A]]) #[[ATTR1]]
527 ; CHECK-NEXT: br label [[CONT2]]
529 ; CHECK-NEXT: tail call void @use1(ptr noundef nonnull dereferenceable(12) [[A]]) #[[ATTR1]]
530 ; CHECK-NEXT: ret void
532 %cmp = icmp eq i8 %c, 0
533 tail call void @use1(ptr dereferenceable(4) %a)
534 br i1 %cmp, label %cont.then, label %cont.else
536 tail call void @use1(ptr dereferenceable(12) %a)
539 tail call void @use1(ptr dereferenceable(16) %a)
542 tail call void @use1(ptr dereferenceable(8) %a)
546 ; void rec-branch-1(int a, int b, int c, int *ptr) {
560 ; FIXME: %ptr should be dereferenceable(4)
561 define dso_local void @rec-branch-1(i32 %a, i32 %b, i32 %c, ptr %ptr) {
562 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write)
563 ; CHECK-LABEL: define {{[^@]+}}@rec-branch-1
564 ; CHECK-SAME: (i32 [[A:%.*]], i32 [[B:%.*]], i32 [[C:%.*]], ptr nocapture nofree writeonly [[PTR:%.*]]) #[[ATTR3]] {
566 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[A]], 0
567 ; CHECK-NEXT: br i1 [[TOBOOL]], label [[IF_ELSE3:%.*]], label [[IF_THEN:%.*]]
569 ; CHECK-NEXT: [[TOBOOL1:%.*]] = icmp eq i32 [[B]], 0
570 ; CHECK-NEXT: br i1 [[TOBOOL1]], label [[IF_ELSE:%.*]], label [[IF_THEN2:%.*]]
572 ; CHECK-NEXT: store i32 1, ptr [[PTR]], align 4
573 ; CHECK-NEXT: br label [[IF_END8:%.*]]
575 ; CHECK-NEXT: store i32 2, ptr [[PTR]], align 4
576 ; CHECK-NEXT: br label [[IF_END8]]
578 ; CHECK-NEXT: [[TOBOOL4:%.*]] = icmp eq i32 [[C]], 0
579 ; CHECK-NEXT: br i1 [[TOBOOL4]], label [[IF_ELSE6:%.*]], label [[IF_THEN5:%.*]]
581 ; CHECK-NEXT: store i32 3, ptr [[PTR]], align 4
582 ; CHECK-NEXT: br label [[IF_END8]]
584 ; CHECK-NEXT: store i32 4, ptr [[PTR]], align 4
585 ; CHECK-NEXT: br label [[IF_END8]]
587 ; CHECK-NEXT: ret void
590 %tobool = icmp eq i32 %a, 0
591 br i1 %tobool, label %if.else3, label %if.then
593 if.then: ; preds = %entry
594 %tobool1 = icmp eq i32 %b, 0
595 br i1 %tobool1, label %if.else, label %if.then2
597 if.then2: ; preds = %if.then
598 store i32 1, ptr %ptr, align 4
601 if.else: ; preds = %if.then
602 store i32 2, ptr %ptr, align 4
605 if.else3: ; preds = %entry
606 %tobool4 = icmp eq i32 %c, 0
607 br i1 %tobool4, label %if.else6, label %if.then5
609 if.then5: ; preds = %if.else3
610 store i32 3, ptr %ptr, align 4
613 if.else6: ; preds = %if.else3
614 store i32 4, ptr %ptr, align 4
617 if.end8: ; preds = %if.then5, %if.else6, %if.then2, %if.else
621 ; void rec-branch-2(int a, int b, int c, int *ptr) {
631 ; rec-branch-2(1, 1, 1, ptr);
634 ; FIXME: %ptr should be dereferenceable(4)
635 define dso_local void @rec-branch-2(i32 %a, i32 %b, i32 %c, ptr %ptr) {
636 ; CHECK: Function Attrs: nofree nosync nounwind memory(argmem: write)
637 ; CHECK-LABEL: define {{[^@]+}}@rec-branch-2
638 ; CHECK-SAME: (i32 [[A:%.*]], i32 [[B:%.*]], i32 [[C:%.*]], ptr nocapture nofree writeonly [[PTR:%.*]]) #[[ATTR5:[0-9]+]] {
640 ; CHECK-NEXT: [[TOBOOL:%.*]] = icmp eq i32 [[A]], 0
641 ; CHECK-NEXT: br i1 [[TOBOOL]], label [[IF_ELSE3:%.*]], label [[IF_THEN:%.*]]
643 ; CHECK-NEXT: [[TOBOOL1:%.*]] = icmp eq i32 [[B]], 0
644 ; CHECK-NEXT: br i1 [[TOBOOL1]], label [[IF_ELSE:%.*]], label [[IF_THEN2:%.*]]
646 ; CHECK-NEXT: store i32 1, ptr [[PTR]], align 4
647 ; CHECK-NEXT: br label [[IF_END8:%.*]]
649 ; CHECK-NEXT: store i32 2, ptr [[PTR]], align 4
650 ; CHECK-NEXT: br label [[IF_END8]]
652 ; CHECK-NEXT: [[TOBOOL4:%.*]] = icmp eq i32 [[C]], 0
653 ; CHECK-NEXT: br i1 [[TOBOOL4]], label [[IF_ELSE6:%.*]], label [[IF_THEN5:%.*]]
655 ; CHECK-NEXT: store i32 3, ptr [[PTR]], align 4
656 ; CHECK-NEXT: br label [[IF_END8]]
658 ; CHECK-NEXT: tail call void @rec-branch-2(i32 noundef 1, i32 noundef 1, i32 noundef 1, ptr nocapture nofree writeonly [[PTR]]) #[[ATTR8:[0-9]+]]
659 ; CHECK-NEXT: br label [[IF_END8]]
661 ; CHECK-NEXT: ret void
664 %tobool = icmp eq i32 %a, 0
665 br i1 %tobool, label %if.else3, label %if.then
667 if.then: ; preds = %entry
668 %tobool1 = icmp eq i32 %b, 0
669 br i1 %tobool1, label %if.else, label %if.then2
671 if.then2: ; preds = %if.then
672 store i32 1, ptr %ptr, align 4
675 if.else: ; preds = %if.then
676 store i32 2, ptr %ptr, align 4
679 if.else3: ; preds = %entry
680 %tobool4 = icmp eq i32 %c, 0
681 br i1 %tobool4, label %if.else6, label %if.then5
683 if.then5: ; preds = %if.else3
684 store i32 3, ptr %ptr, align 4
687 if.else6: ; preds = %if.else3
688 tail call void @rec-branch-2(i32 1, i32 1, i32 1, ptr %ptr)
691 if.end8: ; preds = %if.then5, %if.else6, %if.then2, %if.else
695 declare void @unknown()
696 define void @nonnull_assume_pos(ptr %arg1, ptr %arg2, ptr %arg3, ptr %arg4) {
697 ; ATTRIBUTOR-LABEL: define {{[^@]+}}@nonnull_assume_pos
698 ; ATTRIBUTOR-SAME: (ptr nocapture nofree nonnull readnone dereferenceable(101) [[ARG1:%.*]], ptr nocapture nofree readnone dereferenceable_or_null(31) [[ARG2:%.*]], ptr nocapture nofree nonnull readnone [[ARG3:%.*]], ptr nocapture nofree readnone dereferenceable_or_null(42) [[ARG4:%.*]])
699 ; ATTRIBUTOR-NEXT: call void @llvm.assume(i1 true) #6 [ "nonnull"(ptr undef), "dereferenceable"(ptr undef, i64 1), "dereferenceable"(ptr undef, i64 2), "dereferenceable"(ptr undef, i64 101), "dereferenceable_or_null"(ptr undef, i64 31), "dereferenceable_or_null"(ptr undef, i64 42) ]
700 ; ATTRIBUTOR-NEXT: call void @unknown()
701 ; ATTRIBUTOR-NEXT: ret void
703 ; CHECK-LABEL: define {{[^@]+}}@nonnull_assume_pos
704 ; CHECK-SAME: (ptr nocapture nofree nonnull readnone dereferenceable(101) [[ARG1:%.*]], ptr nocapture nofree readnone dereferenceable_or_null(31) [[ARG2:%.*]], ptr nocapture nofree nonnull readnone [[ARG3:%.*]], ptr nocapture nofree readnone dereferenceable_or_null(42) [[ARG4:%.*]]) {
705 ; CHECK-NEXT: call void @llvm.assume(i1 noundef true) #[[ATTR9:[0-9]+]] [ "nonnull"(ptr [[ARG3]]), "dereferenceable"(ptr [[ARG1]], i64 1), "dereferenceable"(ptr [[ARG1]], i64 2), "dereferenceable"(ptr [[ARG1]], i64 101), "dereferenceable_or_null"(ptr [[ARG2]], i64 31), "dereferenceable_or_null"(ptr [[ARG4]], i64 42) ]
706 ; CHECK-NEXT: call void @unknown()
707 ; CHECK-NEXT: ret void
709 call void @llvm.assume(i1 true) [ "nonnull"(ptr %arg3), "dereferenceable"(ptr %arg1, i64 1), "dereferenceable"(ptr %arg1, i64 2), "dereferenceable"(ptr %arg1, i64 101), "dereferenceable_or_null"(ptr %arg2, i64 31), "dereferenceable_or_null"(ptr %arg4, i64 42)]
713 define void @nonnull_assume_neg(ptr %arg1, ptr %arg2, ptr %arg3) {
714 ; ATTRIBUTOR-LABEL: define {{[^@]+}}@nonnull_assume_neg
715 ; ATTRIBUTOR-SAME: (ptr nocapture nofree readnone [[ARG1:%.*]], ptr nocapture nofree readnone [[ARG2:%.*]], ptr nocapture nofree readnone [[ARG3:%.*]])
716 ; ATTRIBUTOR-NEXT: call void @unknown()
717 ; ATTRIBUTOR-NEXT: call void @llvm.assume(i1 true) [ "dereferenceable"(ptr undef, i64 101), "dereferenceable"(ptr undef, i64 -2), "dereferenceable_or_null"(ptr undef, i64 31) ]
718 ; ATTRIBUTOR-NEXT: ret void
720 ; CHECK-LABEL: define {{[^@]+}}@nonnull_assume_neg
721 ; CHECK-SAME: (ptr nocapture nofree readnone [[ARG1:%.*]], ptr nocapture nofree readnone [[ARG2:%.*]], ptr nocapture nofree readnone [[ARG3:%.*]]) {
722 ; CHECK-NEXT: call void @unknown()
723 ; CHECK-NEXT: call void @llvm.assume(i1 noundef true) [ "dereferenceable"(ptr [[ARG1]], i64 101), "dereferenceable"(ptr [[ARG2]], i64 -2), "dereferenceable_or_null"(ptr [[ARG3]], i64 31) ]
724 ; CHECK-NEXT: ret void
727 call void @llvm.assume(i1 true) ["dereferenceable"(ptr %arg1, i64 101), "dereferenceable"(ptr %arg2, i64 -2), "dereferenceable_or_null"(ptr %arg3, i64 31)]
730 define void @nonnull_assume_call(ptr %arg1, ptr %arg2, ptr %arg3, ptr %arg4) {
731 ; ATTRIBUTOR-LABEL: define {{[^@]+}}@nonnull_assume_call
732 ; ATTRIBUTOR-SAME: (ptr [[ARG1:%.*]], ptr [[ARG2:%.*]], ptr [[ARG3:%.*]], ptr [[ARG4:%.*]])
733 ; ATTRIBUTOR-NEXT: call void @unknown()
734 ; ATTRIBUTOR-NEXT: [[P:%.*]] = call nonnull dereferenceable(101) ptr @unkown_ptr()
735 ; ATTRIBUTOR-NEXT: call void @unknown_use32(ptr nonnull dereferenceable(101) [[P]])
736 ; ATTRIBUTOR-NEXT: call void @unknown_use8(ptr nonnull dereferenceable(42) [[ARG4]])
737 ; ATTRIBUTOR-NEXT: call void @unknown_use8(ptr nonnull [[ARG3]])
738 ; ATTRIBUTOR-NEXT: call void @unknown_use8(ptr nonnull dereferenceable(31) [[ARG2]])
739 ; ATTRIBUTOR-NEXT: call void @unknown_use8(ptr nonnull dereferenceable(2) [[ARG1]])
740 ; ATTRIBUTOR-NEXT: call void @llvm.assume(i1 true) [ "nonnull"(ptr [[ARG3]]), "dereferenceable"(ptr [[ARG1]], i64 1), "dereferenceable"(ptr [[ARG1]], i64 2), "dereferenceable"(ptr [[P]], i64 101), "dereferenceable_or_null"(ptr [[ARG2]], i64 31), "dereferenceable_or_null"(ptr [[ARG4]], i64 42) ]
741 ; ATTRIBUTOR-NEXT: call void @unknown_use8(ptr nonnull dereferenceable(2) [[ARG1]])
742 ; ATTRIBUTOR-NEXT: call void @unknown_use8(ptr nonnull dereferenceable(31) [[ARG2]])
743 ; ATTRIBUTOR-NEXT: call void @unknown_use8(ptr nonnull [[ARG3]])
744 ; ATTRIBUTOR-NEXT: call void @unknown_use8(ptr nonnull dereferenceable(42) [[ARG4]])
745 ; ATTRIBUTOR-NEXT: call void @unknown_use32(ptr nonnull dereferenceable(101) [[P]])
746 ; ATTRIBUTOR-NEXT: call void @unknown()
747 ; ATTRIBUTOR-NEXT: ret void
749 ; CHECK-LABEL: define {{[^@]+}}@nonnull_assume_call
750 ; CHECK-SAME: (ptr [[ARG1:%.*]], ptr [[ARG2:%.*]], ptr [[ARG3:%.*]], ptr [[ARG4:%.*]]) {
751 ; CHECK-NEXT: call void @unknown()
752 ; CHECK-NEXT: [[P:%.*]] = call nonnull dereferenceable(101) ptr @unkown_ptr() #[[ATTR10:[0-9]+]]
753 ; CHECK-NEXT: call void @unknown_use32(ptr nonnull dereferenceable(101) [[P]]) #[[ATTR10]]
754 ; CHECK-NEXT: call void @unknown_use8(ptr dereferenceable_or_null(42) [[ARG4]]) #[[ATTR10]]
755 ; CHECK-NEXT: call void @unknown_use8(ptr nonnull [[ARG3]]) #[[ATTR10]]
756 ; CHECK-NEXT: call void @unknown_use8(ptr dereferenceable_or_null(31) [[ARG2]]) #[[ATTR10]]
757 ; CHECK-NEXT: call void @unknown_use8(ptr nonnull dereferenceable(2) [[ARG1]]) #[[ATTR10]]
758 ; CHECK-NEXT: call void @llvm.assume(i1 noundef true) [ "nonnull"(ptr [[ARG3]]), "dereferenceable"(ptr [[ARG1]], i64 1), "dereferenceable"(ptr [[ARG1]], i64 2), "dereferenceable"(ptr [[P]], i64 101), "dereferenceable_or_null"(ptr [[ARG2]], i64 31), "dereferenceable_or_null"(ptr [[ARG4]], i64 42) ]
759 ; CHECK-NEXT: call void @unknown_use8(ptr nonnull dereferenceable(2) [[ARG1]]) #[[ATTR10]]
760 ; CHECK-NEXT: call void @unknown_use8(ptr dereferenceable_or_null(31) [[ARG2]]) #[[ATTR10]]
761 ; CHECK-NEXT: call void @unknown_use8(ptr nonnull [[ARG3]]) #[[ATTR10]]
762 ; CHECK-NEXT: call void @unknown_use8(ptr dereferenceable_or_null(42) [[ARG4]]) #[[ATTR10]]
763 ; CHECK-NEXT: call void @unknown_use32(ptr nonnull dereferenceable(101) [[P]]) #[[ATTR10]]
764 ; CHECK-NEXT: call void @unknown()
765 ; CHECK-NEXT: ret void
768 %p = call ptr @unkown_ptr()
769 call void @unknown_use32(ptr %p)
770 call void @unknown_use8(ptr %arg4)
771 call void @unknown_use8(ptr %arg3)
772 call void @unknown_use8(ptr %arg2)
773 call void @unknown_use8(ptr %arg1)
774 call void @llvm.assume(i1 true) [ "nonnull"(ptr %arg3), "dereferenceable"(ptr %arg1, i64 1), "dereferenceable"(ptr %arg1, i64 2), "dereferenceable"(ptr %p, i64 101), "dereferenceable_or_null"(ptr %arg2, i64 31), "dereferenceable_or_null"(ptr %arg4, i64 42)]
775 call void @unknown_use8(ptr %arg1)
776 call void @unknown_use8(ptr %arg2)
777 call void @unknown_use8(ptr %arg3)
778 call void @unknown_use8(ptr %arg4)
779 call void @unknown_use32(ptr %p)
783 declare void @unknown_use8(ptr) willreturn nounwind
784 declare void @unknown_use32(ptr) willreturn nounwind
785 declare void @llvm.assume(i1)
788 define void @max_offset(i1 %c) {
789 ; CHECK: Function Attrs: mustprogress nounwind willreturn
790 ; CHECK-LABEL: define {{[^@]+}}@max_offset
791 ; CHECK-SAME: (i1 noundef [[C:%.*]]) #[[ATTR2]] {
793 ; CHECK-NEXT: br i1 [[C]], label [[T:%.*]], label [[F:%.*]]
795 ; CHECK-NEXT: [[GEP:%.*]] = getelementptr i8, ptr @g, i64 2
796 ; CHECK-NEXT: br label [[F]]
798 ; CHECK-NEXT: [[PHI:%.*]] = phi ptr [ [[GEP]], [[T]] ], [ @g, [[ENTRY:%.*]] ]
799 ; CHECK-NEXT: call void @unknown_use8(ptr noundef align 2 dereferenceable_or_null(6) [[PHI]]) #[[ATTR1]]
800 ; CHECK-NEXT: ret void
803 br i1 %c, label %t, label %f
805 %gep = getelementptr i8, ptr @g, i64 2
808 %phi = phi ptr [%gep, %t], [@g, %entry]
809 call void @unknown_use8(ptr %phi)
813 !0 = !{i64 10, i64 100}
816 ; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
817 ; TUNIT: attributes #[[ATTR1]] = { nounwind willreturn }
818 ; TUNIT: attributes #[[ATTR2]] = { mustprogress nounwind willreturn }
819 ; TUNIT: attributes #[[ATTR3]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) }
820 ; TUNIT: attributes #[[ATTR4]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: readwrite) }
821 ; TUNIT: attributes #[[ATTR5]] = { nofree nosync nounwind memory(argmem: write) }
822 ; TUNIT: attributes #[[ATTR6:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }
823 ; TUNIT: attributes #[[ATTR7]] = { nofree nosync nounwind willreturn memory(write) }
824 ; TUNIT: attributes #[[ATTR8]] = { nofree nosync nounwind memory(write) }
825 ; TUNIT: attributes #[[ATTR9]] = { nofree willreturn memory(write) }
826 ; TUNIT: attributes #[[ATTR10]] = { nounwind }
828 ; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) }
829 ; CGSCC: attributes #[[ATTR1]] = { nounwind willreturn }
830 ; CGSCC: attributes #[[ATTR2]] = { mustprogress nounwind willreturn }
831 ; CGSCC: attributes #[[ATTR3]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) }
832 ; CGSCC: attributes #[[ATTR4]] = { mustprogress nofree nosync nounwind willreturn memory(argmem: readwrite) }
833 ; CGSCC: attributes #[[ATTR5]] = { nofree nosync nounwind memory(argmem: write) }
834 ; CGSCC: attributes #[[ATTR6:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: write) }
835 ; CGSCC: attributes #[[ATTR7]] = { nofree nounwind willreturn memory(write) }
836 ; CGSCC: attributes #[[ATTR8]] = { nofree nosync nounwind memory(write) }
837 ; CGSCC: attributes #[[ATTR9]] = { nofree willreturn memory(write) }
838 ; CGSCC: attributes #[[ATTR10]] = { nounwind }
840 ; TUNIT: [[RNG0]] = !{i64 10, i64 100}
842 ; CGSCC: [[RNG0]] = !{i64 10, i64 100}