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
6declare void @func()
7
8define i1 @test_negative(i32 addrspace(1)* %p) gc "statepoint-example" {
9entry:
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) ["gc-live"(i32 addrspace(1)* %p)]
11  %pnew = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token,  i32 0, i32 0)
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
19define i1 @test_nonnull(i32 addrspace(1)* nonnull %p) gc "statepoint-example" {
20entry:
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) ["gc-live"(i32 addrspace(1)* %p)]
22  %pnew = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token,  i32 0, i32 0)
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
29define i1 @test_null() gc "statepoint-example" {
30entry:
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) ["gc-live"(i32 addrspace(1)* null)]
32  %pnew = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token,  i32 0, i32 0)
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
40define i1 @test_undef() gc "statepoint-example" {
41entry:
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) ["gc-live"(i32 addrspace(1)* undef)]
43  %pnew = call i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token %safepoint_token,  i32 0, i32 0)
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
51declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
52declare i32 addrspace(1)* @llvm.experimental.gc.relocate.p1i32(token, i32, i32) #3
53