1 ; RUN: opt < %s -S -rewrite-statepoints-for-gc | FileCheck %s
2 ; RUN: opt < %s -S -passes=rewrite-statepoints-for-gc | FileCheck %s
4 declare i64 addrspace(1)* @some_call(i64 addrspace(1)*)
5 declare i32 @personality_function()
7 define i64 addrspace(1)* @test_basic(i64 addrspace(1)* %obj, i64 addrspace(1)* %obj1) gc "statepoint-example" personality i32 ()* @personality_function {
13 %ret_val = invoke i64 addrspace(1)* @some_call(i64 addrspace(1)* %obj)
14 to label %normal_return unwind label %exceptional_return
16 ; CHECK-LABEL: normal_return:
21 ret i64 addrspace(1)* %ret_val
23 ; CHECK-LABEL: exceptional_return:
28 %landing_pad4 = landingpad token
30 ret i64 addrspace(1)* %obj1
33 declare <4 x i64 addrspace(1)*> @some_vector_call(<4 x i64 addrspace(1)*>)
35 define <4 x i64 addrspace(1)*> @test_basic_vector(<4 x i64 addrspace(1)*> %objs, <4 x i64 addrspace(1)*> %objs1) gc "statepoint-example" personality i32 ()* @personality_function {
36 ; CHECK-LABEL: @test_basic_vector
38 ; CHECK: invoke{{.*}}llvm.experimental.gc.statepoint{{.*}}some_vector_call
39 %ret_val = invoke <4 x i64 addrspace(1)*> @some_vector_call(<4 x i64 addrspace(1)*> %objs)
40 to label %normal_return unwind label %exceptional_return
42 ; CHECK-LABEL: normal_return:
44 ; CHECK: ret <4 x i64 addrspace(1)*>
47 ret <4 x i64 addrspace(1)*> %ret_val
49 ; CHECK-LABEL: exceptional_return:
51 ; CHECK: ret <4 x i64 addrspace(1)*>
54 %landing_pad4 = landingpad token
56 ret <4 x i64 addrspace(1)*> %objs1
59 define i64 addrspace(1)* @test_two_invokes(i64 addrspace(1)* %obj, i64 addrspace(1)* %obj1) gc "statepoint-example" personality i32 ()* @personality_function {
65 %ret_val1 = invoke i64 addrspace(1)* @some_call(i64 addrspace(1)* %obj)
66 to label %second_invoke unwind label %exceptional_return
68 ; CHECK-LABEL: second_invoke:
73 %ret_val2 = invoke i64 addrspace(1)* @some_call(i64 addrspace(1)* %ret_val1)
74 to label %normal_return unwind label %exceptional_return
76 ; CHECK-LABEL: normal_return:
80 ret i64 addrspace(1)* %ret_val2
82 ; CHECK: exceptional_return:
86 %landing_pad4 = landingpad token
88 ret i64 addrspace(1)* %obj1
91 define i64 addrspace(1)* @test_phi_node(i1 %cond, i64 addrspace(1)* %obj) gc "statepoint-example" personality i32 ()* @personality_function {
92 ; CHECK-LABEL: @test_phi_node
95 br i1 %cond, label %left, label %right
98 %ret_val_left = invoke i64 addrspace(1)* @some_call(i64 addrspace(1)* %obj)
99 to label %merge unwind label %exceptional_return
102 %ret_val_right = invoke i64 addrspace(1)* @some_call(i64 addrspace(1)* %obj)
103 to label %merge unwind label %exceptional_return
105 ; CHECK: merge[[A:[0-9]]]:
107 ; CHECK: br label %[[with_phi:merge[0-9]*]]
109 ; CHECK: merge[[B:[0-9]]]:
111 ; CHECK: br label %[[with_phi]]
113 ; CHECK: [[with_phi]]:
115 ; CHECK: ret i64 addrspace(1)* %ret_val
117 %ret_val = phi i64 addrspace(1)* [%ret_val_left, %left], [%ret_val_right, %right]
118 ret i64 addrspace(1)* %ret_val
120 ; CHECK-LABEL: exceptional_return:
121 ; CHECK: ret i64 addrspace(1)*
124 %landing_pad4 = landingpad token
126 ret i64 addrspace(1)* %obj
129 declare void @do_safepoint()
130 define void @gc.safepoint_poll() {
131 ; CHECK-LABEL: gc.safepoint_poll
133 ; CHECK-NEXT: do_safepoint
134 ; CHECK-NEXT: ret void
136 call void @do_safepoint()