1 ; RUN: opt < %s -instcombine -S | FileCheck %s 2 ; These tests check the optimizations specific to 3 ; pointers being relocated at a statepoint. 4 5 6 declare void @func() 7 8 define i1 @test_negative(i32 addrspace(1)* %p) gc "statepoint-example" { 9 entry: 10 %safepoint_token = tail call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @func, i32 0, i32 0, i32 0, i32 0, i32 addrspace(1)* %p) 11 %pnew = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token, i32 7, i32 7) 12 %cmp = icmp eq i32 addrspace(1)* %pnew, null 13 ret i1 %cmp 14 ; CHECK-LABEL: test_negative 15 ; CHECK: %pnew = call i32 addrspace(1)* 16 ; CHECK: ret i1 %cmp 17 } 18 19 define i1 @test_nonnull(i32 addrspace(1)* nonnull %p) gc "statepoint-example" { 20 entry: 21 %safepoint_token = tail call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @func, i32 0, i32 0, i32 0, i32 0, i32 addrspace(1)* %p) 22 %pnew = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token, i32 7, i32 7) 23 %cmp = icmp eq i32 addrspace(1)* %pnew, null 24 ret i1 %cmp 25 ; CHECK-LABEL: test_nonnull 26 ; CHECK: ret i1 false 27 } 28 29 define i1 @test_null() gc "statepoint-example" { 30 entry: 31 %safepoint_token = tail call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @func, i32 0, i32 0, i32 0, i32 0, i32 addrspace(1)* null) 32 %pnew = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token, i32 7, i32 7) 33 %cmp = icmp eq i32 addrspace(1)* %pnew, null 34 ret i1 %cmp 35 ; CHECK-LABEL: test_null 36 ; CHECK-NOT: %pnew 37 ; CHECK: ret i1 true 38 } 39 40 define i1 @test_undef() gc "statepoint-example" { 41 entry: 42 %safepoint_token = tail call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @func, i32 0, i32 0, i32 0, i32 0, i32 addrspace(1)* undef) 43 %pnew = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token, i32 7, i32 7) 44 %cmp = icmp eq i32 addrspace(1)* %pnew, null 45 ret i1 %cmp 46 ; CHECK-LABEL: test_undef 47 ; CHECK-NOT: %pnew 48 ; CHECK: ret i1 undef 49 } 50 51 declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...) 52 declare i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token, i32, i32) #3 53