1 ; RUN: opt -S -rewrite-statepoints-for-gc %s | FileCheck %s
4 declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
6 ; constants don't get relocated.
7 define i8 @test() gc "statepoint-example" {
10 ; CHECK-NEXT: load i8, i8 addrspace(1)* inttoptr (i64 15 to i8 addrspace(1)*)
12 call i32 (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @foo, i32 0, i32 0, i32 0, i32 0)
13 %res = load i8, i8 addrspace(1)* inttoptr (i64 15 to i8 addrspace(1)*)
18 ; Mostly just here to show reasonable code test can come from.
19 define i8 @test2(i8 addrspace(1)* %p) gc "statepoint-example" {
21 ; CHECK: gc.statepoint
22 ; CHECK-NEXT: gc.relocate
25 call i32 (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @foo, i32 0, i32 0, i32 0, i32 0)
26 %cmp = icmp eq i8 addrspace(1)* %p, null
27 br i1 %cmp, label %taken, label %not_taken
33 %cmp2 = icmp ne i8 addrspace(1)* %p, null
34 br i1 %cmp2, label %taken, label %dead
37 ; We see that dead can't be reached, but the optimizer might not. It's
38 ; completely legal for it to exploit the fact that if dead executed, %p
39 ; would have to equal null. This can produce intermediate states which
40 ; look like that of test above, even if arbitrary constant addresses aren't
41 ; legal in the source language
42 %addr = getelementptr i8, i8 addrspace(1)* %p, i32 15
43 %res = load i8, i8addrspace(1)* %addr
47 @G = addrspace(1) global i8 5
49 ; Globals don't move and thus don't get relocated
50 define i8 @test3(i1 %always_true) gc "statepoint-example" {
52 ; CHECK: gc.statepoint
53 ; CHECK-NEXT: load i8, i8 addrspace(1)* @G
55 call i32 (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @foo, i32 0, i32 0, i32 0, i32 0)
56 %res = load i8, i8 addrspace(1)* @G, align 1