1 ; RUN: opt -safepoint-ir-verifier-print-only -verify-safepoint-ir -S %s 2>&1 | FileCheck %s
3 define ptr addrspace(1) @test.not.ok.0(ptr addrspace(1) %arg) gc "statepoint-example" {
4 ; CHECK-LABEL: Verifying gc pointers in function: test.not.ok.0
6 br i1 undef, label %left, label %right
9 %safepoint_token = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void ()) undef, i32 0, i32 0, i32 0, i32 0)
16 ; CHECK: Illegal use of unrelocated value found!
17 ; CHECK-NEXT: Def: %val = phi ptr addrspace(1) [ %arg, %left ], [ %arg, %right ]
18 ; CHECK-NEXT: Use: ret ptr addrspace(1) %val
19 %val = phi ptr addrspace(1) [ %arg, %left ], [ %arg, %right ]
20 ret ptr addrspace(1) %val
23 define ptr addrspace(1) @test.not.ok.1(ptr addrspace(1) %arg) gc "statepoint-example" {
24 ; CHECK-LABEL: Verifying gc pointers in function: test.not.ok.1
26 br i1 undef, label %left, label %right
29 %safepoint_token = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void ()) undef, i32 0, i32 0, i32 0, i32 0)
36 ; CHECK: Illegal use of unrelocated value found!
37 ; CHECK-NEXT: Def: %val = phi ptr addrspace(1) [ %arg, %left ], [ null, %right ]
38 ; CHECK-NEXT: Use: ret ptr addrspace(1) %val
39 %val = phi ptr addrspace(1) [ %arg, %left ], [ null, %right ]
40 ret ptr addrspace(1) %val
43 define ptr addrspace(1) @test.ok.0(ptr addrspace(1) %arg) gc "statepoint-example" {
44 ; CHECK: No illegal uses found by SafepointIRVerifier in: test.ok.0
46 br i1 undef, label %left, label %right
49 %safepoint_token = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void ()) undef, i32 0, i32 0, i32 0, i32 0)
56 %val = phi ptr addrspace(1) [ null, %left ], [ null, %right]
57 ret ptr addrspace(1) %val
60 define ptr addrspace(1) @test.ok.1(ptr addrspace(1) %arg) gc "statepoint-example" {
61 ; CHECK: No illegal uses found by SafepointIRVerifier in: test.ok.1
63 br i1 undef, label %left, label %right
66 call void @not_statepoint()
73 %val = phi ptr addrspace(1) [ %arg, %left ], [ %arg, %right]
74 ret ptr addrspace(1) %val
77 ; It should be allowed to compare poisoned ptr with null.
78 define void @test.poisoned.cmp.ok(ptr addrspace(1) %arg) gc "statepoint-example" {
79 ; CHECK-LABEL: Verifying gc pointers in function: test.poisoned.cmp.ok
81 br i1 undef, label %left, label %right
84 %safepoint_token = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void ()) undef, i32 0, i32 0, i32 0, i32 0) ["gc-live"(ptr addrspace(1) %arg)]
85 %arg.relocated = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %safepoint_token, i32 0, i32 0) ; arg, arg
89 %safepoint_token2 = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void ()) undef, i32 0, i32 0, i32 0, i32 0) ["gc-live"(ptr addrspace(1) %arg)]
93 ; CHECK: No illegal uses found by SafepointIRVerifier in: test.poisoned.cmp.ok
94 %val.poisoned = phi ptr addrspace(1) [ %arg.relocated, %left ], [ %arg, %right ]
95 %c = icmp eq ptr addrspace(1) %val.poisoned, null
99 ; It is illegal to compare poisoned ptr and relocated.
100 define void @test.poisoned.cmp.fail.0(ptr addrspace(1) %arg) gc "statepoint-example" {
101 ; CHECK-LABEL: Verifying gc pointers in function: test.poisoned.cmp.fail.0
103 br i1 undef, label %left, label %right
106 %safepoint_token = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void ()) undef, i32 0, i32 0, i32 0, i32 0) ["gc-live"(ptr addrspace(1) %arg)]
107 %arg.relocated = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %safepoint_token, i32 0, i32 0) ; arg, arg
111 %safepoint_token2 = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void ()) undef, i32 0, i32 0, i32 0, i32 0) ["gc-live"(ptr addrspace(1) %arg), "deopt"(i32 -1, i32 0, i32 0, i32 0)]
112 %arg.relocated2 = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %safepoint_token2, i32 0, i32 0) ; arg, arg
116 ; CHECK: Illegal use of unrelocated value found!
117 ; CHECK-NEXT: Def: %val.poisoned = phi ptr addrspace(1) [ %arg.relocated, %left ], [ %arg, %right ]
118 ; CHECK-NEXT: Use: %c = icmp eq ptr addrspace(1) %val.poisoned, %val
119 %val.poisoned = phi ptr addrspace(1) [ %arg.relocated, %left ], [ %arg, %right ]
120 %val = phi ptr addrspace(1) [ %arg.relocated, %left ], [ %arg.relocated2, %right ]
121 %c = icmp eq ptr addrspace(1) %val.poisoned, %val
125 ; It is illegal to compare poisoned ptr and unrelocated.
126 define void @test.poisoned.cmp.fail.1(ptr addrspace(1) %arg) gc "statepoint-example" {
127 ; CHECK-LABEL: Verifying gc pointers in function: test.poisoned.cmp.fail.1
129 br i1 undef, label %left, label %right
132 %safepoint_token = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void ()) undef, i32 0, i32 0, i32 0, i32 0) ["gc-live"(ptr addrspace(1) %arg)]
133 %arg.relocated = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %safepoint_token, i32 0, i32 0) ; arg, arg
137 %safepoint_token2 = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void ()) undef, i32 0, i32 0, i32 0, i32 0) ["gc-live"(ptr addrspace(1) %arg), "deopt"(i32 -1, i32 0, i32 0, i32 0)]
138 %arg.relocated2 = call ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token %safepoint_token2, i32 0, i32 0) ; arg, arg
142 ; CHECK: Illegal use of unrelocated value found!
143 ; CHECK-NEXT: Def: %val.poisoned = phi ptr addrspace(1) [ %arg.relocated, %left ], [ %arg, %right ]
144 ; CHECK-NEXT: Use: %c = icmp eq ptr addrspace(1) %val.poisoned, %arg
145 %val.poisoned = phi ptr addrspace(1) [ %arg.relocated, %left ], [ %arg, %right ]
146 %c = icmp eq ptr addrspace(1) %val.poisoned, %arg
150 ; It should be allowed to compare unrelocated phi with unrelocated value.
151 define void @test.unrelocated-phi.cmp.ok(ptr addrspace(1) %arg) gc "statepoint-example" {
152 ; CHECK-LABEL: Verifying gc pointers in function: test.unrelocated-phi.cmp.ok
154 br i1 undef, label %left, label %right
157 %safepoint_token = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 0, i32 0, ptr elementtype(void ()) undef, i32 0, i32 0, i32 0, i32 0)
164 ; CHECK: No illegal uses found by SafepointIRVerifier in: test.unrelocated-phi.cmp.ok
165 %val.unrelocated = phi ptr addrspace(1) [ %arg, %left ], [ null, %right ]
166 %c = icmp eq ptr addrspace(1) %val.unrelocated, %arg
170 declare token @llvm.experimental.gc.statepoint.p0(i64, i32, ptr, i32, i32, ...)
171 declare ptr addrspace(1) @llvm.experimental.gc.relocate.p1(token, i32, i32)
172 declare void @not_statepoint()