1; RUN: opt %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
2
3
4; CHECK: derived %obj_to_consume base %base_phi
5
6declare void @foo()
7declare i64 addrspace(1)* @generate_obj()
8declare void @consume_obj(i64 addrspace(1)*)
9
10define void @test(i32 %condition) gc "statepoint-example" {
11entry:
12  br label %loop
13
14loop:
15; CHECK: loop:
16; CHECK:  %safepoint_token1 = call i32 (i64 addrspace(1)* ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_p1i64f(i64 addrspace(1)* ()* @generate_obj, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i3
17; CHECK-NEXT:  %obj2 = call i64 addrspace(1)* @llvm.experimental.gc.result
18  %safepoint_token1 = call i32 (i64 addrspace(1)* ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_p1i64f(i64 addrspace(1)* ()* @generate_obj, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0)
19  %obj2 = call i64 addrspace(1)* @llvm.experimental.gc.result.p1i64(i32 %safepoint_token1)
20  switch i32 %condition, label %dest_a [
21    i32 0, label %dest_b
22    i32 1, label %dest_c
23  ]
24
25dest_a:
26  br label %merge
27
28dest_b:
29  br label %merge
30
31dest_c:
32  br label %merge
33
34merge:
35; CHECK: merge:
36; CHECK:  %base_phi = phi i64 addrspace(1)* [ %obj2, %dest_a ], [ null, %dest_b ], [ null, %dest_c ]
37; CHECK:  %obj_to_consume = phi i64 addrspace(1)* [ %obj2, %dest_a ], [ null, %dest_b ], [ null, %dest_c ]
38
39  %obj_to_consume = phi i64 addrspace(1)* [ %obj2, %dest_a ], [ null, %dest_b ], [ null, %dest_c ]
40  %safepoint_token3 = call i32 (void (i64 addrspace(1)*)*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidp1i64f(void (i64 addrspace(1)*)* @consume_obj, i32 1, i32 0, i64 addrspace(1)* %obj_to_consume, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0)
41  br label %merge.split
42
43merge.split:                                      ; preds = %merge
44  %safepoint_token = call i32 (void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(void ()* @foo, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0)
45  br label %loop
46}
47
48
49; Function Attrs: nounwind
50declare i64 addrspace(1)* @llvm.experimental.gc.result.p1i64(i32) #0
51declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidf(void ()*, i32, i32, ...)
52declare i32 @llvm.experimental.gc.statepoint.p0f_p1i64f(i64 addrspace(1)* ()*, i32, i32, ...)
53declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidp1i64f(void (i64 addrspace(1)*)*, i32, i32, ...)
54