1 ; RUN: opt -safepoint-ir-verifier-print-only -verify-safepoint-ir -S %s 2>&1 | FileCheck %s
3 define ptr addrspace(1) @test1(i64 %arg) gc "statepoint-example" {
4 ; CHECK: No illegal uses found by SafepointIRVerifier in: test1
6 %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)
7 ret ptr addrspace(1) null
10 define ptr addrspace(1) @test2(i64 %arg) gc "statepoint-example" {
11 ; CHECK: No illegal uses found by SafepointIRVerifier in: test2
13 %load_addr = getelementptr i8, ptr addrspace(1) inttoptr (i64 15 to ptr addrspace(1)), i64 %arg
14 %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)
15 ret ptr addrspace(1) %load_addr
18 define ptr addrspace(1) @test3(i64 %arg) gc "statepoint-example" {
19 ; CHECK: No illegal uses found by SafepointIRVerifier in: test3
21 %load_addr = getelementptr i32, ptr addrspace(1) inttoptr (i64 15 to ptr addrspace(1)), i64 %arg
22 %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)
23 ret ptr addrspace(1) %load_addr
26 define ptr addrspace(1) @test4(i64 %arg, i1 %cond) gc "statepoint-example" {
27 ; CHECK: No illegal uses found by SafepointIRVerifier in: test4
29 %load_addr.1 = getelementptr i8, ptr addrspace(1) inttoptr (i64 15 to ptr addrspace(1)), i64 %arg
30 br i1 %cond, label %split, label %join
33 %load_addr.2 = getelementptr i8, ptr addrspace(1) inttoptr (i64 30 to ptr addrspace(1)), i64 %arg
37 %load_addr = phi ptr addrspace(1) [%load_addr.1, %entry], [%load_addr.2, %split]
38 %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)
39 ret ptr addrspace(1) %load_addr
42 define ptr addrspace(1) @test5(i64 %arg, i1 %cond) gc "statepoint-example" {
43 ; CHECK: No illegal uses found by SafepointIRVerifier in: test5
45 %load_addr.1 = getelementptr i8, ptr addrspace(1) inttoptr (i64 15 to ptr addrspace(1)), i64 %arg
46 %load_addr.2 = getelementptr i8, ptr addrspace(1) inttoptr (i64 30 to ptr addrspace(1)), i64 %arg
47 %load_addr = select i1 %cond, ptr addrspace(1) %load_addr.1, ptr addrspace(1) %load_addr.2
48 %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)
49 ret ptr addrspace(1) %load_addr
52 define ptr addrspace(1) @test6(i64 %arg, i1 %cond, ptr addrspace(1) %base) gc "statepoint-example" {
53 ; CHECK-LABEL: Verifying gc pointers in function: test6
54 ; CHECK: Illegal use of unrelocated value found!
56 %load_addr.1 = getelementptr i8, ptr addrspace(1) %base, i64 %arg
57 br i1 %cond, label %split, label %join
60 %load_addr.2 = getelementptr i8, ptr addrspace(1) inttoptr (i64 30 to ptr addrspace(1)), i64 %arg
64 %load_addr = phi ptr addrspace(1) [%load_addr.1, %entry], [%load_addr.2, %split]
65 %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)
66 ret ptr addrspace(1) %load_addr
69 declare token @llvm.experimental.gc.statepoint.p0(i64, i32, ptr, i32, i32, ...)