1 ; RUN: opt -inline -S < %s | FileCheck %s
3 ; The callee guarantees that the pointer argument is nonnull and dereferenceable.
4 ; That information should transfer to the caller.
6 define i32 @callee(i32* dereferenceable(32) %t1) {
7 ; CHECK-LABEL: @callee(i32* dereferenceable(32) %t1)
8 ; CHECK-NEXT: [[T2:%.*]] = load i32, i32* %t1
9 ; CHECK-NEXT: ret i32 [[T2]]
11 %t2 = load i32, i32* %t1
15 ; FIXME: All dereferenceability information is lost.
16 ; The caller argument could be known nonnull and dereferenceable(32).
18 define i32 @caller1(i32* %t1) {
19 ; CHECK-LABEL: @caller1(i32* %t1)
20 ; CHECK-NEXT: [[T2_I:%.*]] = load i32, i32* %t1
21 ; CHECK-NEXT: ret i32 [[T2_I]]
23 %t2 = tail call i32 @callee(i32* dereferenceable(32) %t1)
27 ; The caller argument is nonnull, but that can be explicit.
28 ; The dereferenceable amount could be increased.
30 define i32 @caller2(i32* dereferenceable(31) %t1) {
31 ; CHECK-LABEL: @caller2(i32* dereferenceable(31) %t1)
32 ; CHECK-NEXT: [[T2_I:%.*]] = load i32, i32* %t1
33 ; CHECK-NEXT: ret i32 [[T2_I]]
35 %t2 = tail call i32 @callee(i32* dereferenceable(32) %t1)
39 ; The caller argument is nonnull, but that can be explicit.
40 ; Make sure that we don't propagate a smaller dereferenceable amount.
42 define i32 @caller3(i32* dereferenceable(33) %t1) {
43 ; CHECK-LABEL: @caller3(i32* dereferenceable(33) %t1)
44 ; CHECK-NEXT: [[T2_I:%.*]] = load i32, i32* %t1
45 ; CHECK-NEXT: ret i32 [[T2_I]]
47 %t2 = tail call i32 @callee(i32* dereferenceable(32) %t1)