1 ; RUN: opt < %s -S -passes=rewrite-statepoints-for-gc | FileCheck %s
3 declare ptr addrspace(1) @some_call(ptr addrspace(1))
4 declare i32 @personality_function()
6 define ptr addrspace(1) @test_basic(ptr addrspace(1) %obj, ptr addrspace(1) %obj1) gc "statepoint-example" personality ptr @personality_function {
12 %ret_val = invoke ptr addrspace(1) @some_call(ptr addrspace(1) %obj)
13 to label %normal_return unwind label %exceptional_return
15 ; CHECK-LABEL: normal_return:
20 ret ptr addrspace(1) %ret_val
22 ; CHECK-LABEL: exceptional_return:
27 %landing_pad4 = landingpad token
29 ret ptr addrspace(1) %obj1
32 declare <4 x ptr addrspace(1)> @some_vector_call(<4 x ptr addrspace(1)>)
34 define <4 x ptr addrspace(1)> @test_basic_vector(<4 x ptr addrspace(1)> %objs, <4 x ptr addrspace(1)> %objs1) gc "statepoint-example" personality ptr @personality_function {
35 ; CHECK-LABEL: @test_basic_vector
37 ; CHECK: invoke{{.*}}llvm.experimental.gc.statepoint{{.*}}some_vector_call
38 %ret_val = invoke <4 x ptr addrspace(1)> @some_vector_call(<4 x ptr addrspace(1)> %objs)
39 to label %normal_return unwind label %exceptional_return
41 ; CHECK-LABEL: normal_return:
43 ; CHECK: ret <4 x ptr addrspace(1)>
46 ret <4 x ptr addrspace(1)> %ret_val
48 ; CHECK-LABEL: exceptional_return:
50 ; CHECK: ret <4 x ptr addrspace(1)>
53 %landing_pad4 = landingpad token
55 ret <4 x ptr addrspace(1)> %objs1
58 define ptr addrspace(1) @test_two_invokes(ptr addrspace(1) %obj, ptr addrspace(1) %obj1) gc "statepoint-example" personality ptr @personality_function {
64 %ret_val1 = invoke ptr addrspace(1) @some_call(ptr addrspace(1) %obj)
65 to label %second_invoke unwind label %exceptional_return
67 ; CHECK-LABEL: second_invoke:
72 %ret_val2 = invoke ptr addrspace(1) @some_call(ptr addrspace(1) %ret_val1)
73 to label %normal_return unwind label %exceptional_return
75 ; CHECK-LABEL: normal_return:
79 ret ptr addrspace(1) %ret_val2
81 ; CHECK: exceptional_return:
85 %landing_pad4 = landingpad token
87 ret ptr addrspace(1) %obj1
90 define ptr addrspace(1) @test_phi_node(i1 %cond, ptr addrspace(1) %obj) gc "statepoint-example" personality ptr @personality_function {
91 ; CHECK-LABEL: @test_phi_node
94 br i1 %cond, label %left, label %right
97 %ret_val_left = invoke ptr addrspace(1) @some_call(ptr addrspace(1) %obj)
98 to label %merge unwind label %exceptional_return
101 %ret_val_right = invoke ptr addrspace(1) @some_call(ptr addrspace(1) %obj)
102 to label %merge unwind label %exceptional_return
104 ; CHECK: merge[[A:[0-9]]]:
106 ; CHECK: br label %[[with_phi:merge[0-9]*]]
108 ; CHECK: merge[[B:[0-9]]]:
110 ; CHECK: br label %[[with_phi]]
112 ; CHECK: [[with_phi]]:
114 ; CHECK: ret ptr addrspace(1) %ret_val
116 %ret_val = phi ptr addrspace(1) [%ret_val_left, %left], [%ret_val_right, %right]
117 ret ptr addrspace(1) %ret_val
119 ; CHECK-LABEL: exceptional_return:
120 ; CHECK: ret ptr addrspace(1)
123 %landing_pad4 = landingpad token
125 ret ptr addrspace(1) %obj
128 declare void @do_safepoint()
129 define void @gc.safepoint_poll() {
130 ; CHECK-LABEL: gc.safepoint_poll
132 ; CHECK-NEXT: do_safepoint
133 ; CHECK-NEXT: ret void
135 call void @do_safepoint()