1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 2
2 ; RUN: opt -passes=inline < %s -S | FileCheck %s
4 ; Test that instsimplify invoked by the inliner respects null_pointer_is_valid
5 ; (by ensuring that the instruction is inserted into the function when invoking
8 define internal i1 @f(ptr %p) null_pointer_is_valid {
9 %g = getelementptr inbounds i8, ptr %p, i32 -1
10 %r = icmp eq ptr %g, null
14 define i1 @g(ptr %p) null_pointer_is_valid {
15 ; CHECK-LABEL: define i1 @g
16 ; CHECK-SAME: (ptr [[P:%.*]]) #[[ATTR0:[0-9]+]] {
17 ; CHECK-NEXT: [[G_I:%.*]] = getelementptr inbounds i8, ptr [[P]], i32 -1
18 ; CHECK-NEXT: [[R_I:%.*]] = icmp eq ptr [[G_I]], null
19 ; CHECK-NEXT: ret i1 [[R_I]]
21 %r = call i1 @f(ptr %p)
25 define internal i1 @f2(ptr %p) {
26 %g = getelementptr inbounds i8, ptr %p, i32 -1
27 %r = icmp eq ptr %g, null
31 define i1 @g2(ptr %p) null_pointer_is_valid {
32 ; CHECK-LABEL: define i1 @g2
33 ; CHECK-SAME: (ptr [[P:%.*]]) #[[ATTR0]] {
34 ; CHECK-NEXT: [[G_I:%.*]] = getelementptr inbounds i8, ptr [[P]], i32 -1
35 ; CHECK-NEXT: [[R_I:%.*]] = icmp eq ptr [[G_I]], null
36 ; CHECK-NEXT: ret i1 [[R_I]]
38 %r = call i1 @f2(ptr %p)