1 ; RUN: opt -safepoint-ir-verifier-print-only -verify-safepoint-ir -S %s 2>&1 | FileCheck %s
3 define i8 addrspace(1)* @test.not.ok.0(i8 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, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* undef, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0)
16 ; CHECK: Illegal use of unrelocated value found!
17 ; CHECK-NEXT: Def: %val = phi i8 addrspace(1)* [ %arg, %left ], [ %arg, %right ]
18 ; CHECK-NEXT: Use: ret i8 addrspace(1)* %val
19 %val = phi i8 addrspace(1)* [ %arg, %left ], [ %arg, %right ]
20 ret i8 addrspace(1)* %val
23 define i8 addrspace(1)* @test.not.ok.1(i8 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, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* undef, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0)
36 ; CHECK: Illegal use of unrelocated value found!
37 ; CHECK-NEXT: Def: %val = phi i8 addrspace(1)* [ %arg, %left ], [ null, %right ]
38 ; CHECK-NEXT: Use: ret i8 addrspace(1)* %val
39 %val = phi i8 addrspace(1)* [ %arg, %left ], [ null, %right ]
40 ret i8 addrspace(1)* %val
43 define i8 addrspace(1)* @test.ok.0(i8 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, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* undef, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0)
56 %val = phi i8 addrspace(1)* [ null, %left ], [ null, %right]
57 ret i8 addrspace(1)* %val
60 define i8 addrspace(1)* @test.ok.1(i8 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 i8 addrspace(1)* [ %arg, %left ], [ %arg, %right]
74 ret i8 addrspace(1)* %val
77 ; It should be allowed to compare poisoned ptr with null.
78 define void @test.poisoned.cmp.ok(i8 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, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* undef, i32 0, i32 0, i32 0, i32 0, i8 addrspace(1)* %arg , i32 -1, i32 0, i32 0, i32 0)
85 %arg.relocated = call i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %safepoint_token, i32 7, i32 7) ; arg, arg
89 %safepoint_token2 = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* undef, i32 0, i32 0, i32 0, i32 0, i8 addrspace(1)* %arg , i32 -1, i32 0, i32 0, i32 0)
93 ; CHECK: No illegal uses found by SafepointIRVerifier in: test.poisoned.cmp.ok
94 %val.poisoned = phi i8 addrspace(1)* [ %arg.relocated, %left ], [ %arg, %right ]
95 %c = icmp eq i8 addrspace(1)* %val.poisoned, null
99 ; It is illegal to compare poisoned ptr and relocated.
100 define void @test.poisoned.cmp.fail.0(i8 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, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* undef, i32 0, i32 0, i32 0, i32 0, i8 addrspace(1)* %arg , i32 -1, i32 0, i32 0, i32 0)
107 %arg.relocated = call i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %safepoint_token, i32 7, i32 7) ; arg, arg
111 %safepoint_token2 = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* undef, i32 0, i32 0, i32 0, i32 0, i8 addrspace(1)* %arg , i32 -1, i32 0, i32 0, i32 0)
112 %arg.relocated2 = call i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %safepoint_token2, i32 7, i32 7) ; arg, arg
116 ; CHECK: Illegal use of unrelocated value found!
117 ; CHECK-NEXT: Def: %val.poisoned = phi i8 addrspace(1)* [ %arg.relocated, %left ], [ %arg, %right ]
118 ; CHECK-NEXT: Use: %c = icmp eq i8 addrspace(1)* %val.poisoned, %val
119 %val.poisoned = phi i8 addrspace(1)* [ %arg.relocated, %left ], [ %arg, %right ]
120 %val = phi i8 addrspace(1)* [ %arg.relocated, %left ], [ %arg.relocated2, %right ]
121 %c = icmp eq i8 addrspace(1)* %val.poisoned, %val
125 ; It is illegal to compare poisoned ptr and unrelocated.
126 define void @test.poisoned.cmp.fail.1(i8 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, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* undef, i32 0, i32 0, i32 0, i32 0, i8 addrspace(1)* %arg , i32 -1, i32 0, i32 0, i32 0)
133 %arg.relocated = call i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %safepoint_token, i32 7, i32 7) ; arg, arg
137 %safepoint_token2 = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* undef, i32 0, i32 0, i32 0, i32 0, i8 addrspace(1)* %arg , i32 -1, i32 0, i32 0, i32 0)
138 %arg.relocated2 = call i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token %safepoint_token2, i32 7, i32 7) ; arg, arg
142 ; CHECK: Illegal use of unrelocated value found!
143 ; CHECK-NEXT: Def: %val.poisoned = phi i8 addrspace(1)* [ %arg.relocated, %left ], [ %arg, %right ]
144 ; CHECK-NEXT: Use: %c = icmp eq i8 addrspace(1)* %val.poisoned, %arg
145 %val.poisoned = phi i8 addrspace(1)* [ %arg.relocated, %left ], [ %arg, %right ]
146 %c = icmp eq i8 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(i8 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, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* undef, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0)
164 ; CHECK: No illegal uses found by SafepointIRVerifier in: test.unrelocated-phi.cmp.ok
165 %val.unrelocated = phi i8 addrspace(1)* [ %arg, %left ], [ null, %right ]
166 %c = icmp eq i8 addrspace(1)* %val.unrelocated, %arg
170 declare token @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
171 declare i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token, i32, i32)
172 declare void @not_statepoint()