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