llvm.org GIT mirror llvm / b05b70b
Add few simple tests to check statepoint placement for invoke instructions. Differential Revision: http://reviews.llvm.org/D7535 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229842 91177308-0d34-0410-b5e6-96231b3b80d8 Igor Laevsky 4 years ago
1 changed file(s) with 110 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 ; RUN: opt %s -S -place-safepoints | FileCheck %s
1
2 declare i64 addrspace(1)* @"some_call"(i64 addrspace(1)*)
3 declare i32 @"personality_function"()
4
5 define i64 addrspace(1)* @test_basic(i64 addrspace(1)* %obj, i64 addrspace(1)* %obj1) {
6 ; CHECK-LABEL: entry:
7 entry:
8 ; CHECK: invoke
9 ; CHECK: statepoint
10 ; CHECK: some_call
11 %ret_val = invoke i64 addrspace(1)* @"some_call"(i64 addrspace(1)* %obj)
12 to label %normal_return unwind label %exceptional_return
13
14 ; CHECK-LABEL: normal_return:
15 ; CHECK: gc.result
16 ; CHECK: ret i64
17
18 normal_return:
19 ret i64 addrspace(1)* %ret_val
20
21 ; CHECK-LABEL: exceptional_return:
22 ; CHECK: landingpad
23 ; CHECK: ret i64
24
25 exceptional_return:
26 %landing_pad4 = landingpad {i8*, i32} personality i32 ()* @"personality_function"
27 cleanup
28 ret i64 addrspace(1)* %obj1
29 }
30
31 define i64 addrspace(1)* @test_two_invokes(i64 addrspace(1)* %obj, i64 addrspace(1)* %obj1) {
32 ; CHECK-LABEL: entry:
33 entry:
34 ; CHECK: invoke
35 ; CHECK: statepoint
36 ; CHECK: some_call
37 %ret_val1 = invoke i64 addrspace(1)* @"some_call"(i64 addrspace(1)* %obj)
38 to label %second_invoke unwind label %exceptional_return
39
40 ; CHECK-LABEL: second_invoke:
41 second_invoke:
42 ; CHECK: invoke
43 ; CHECK: statepoint
44 ; CHECK: some_call
45 %ret_val2 = invoke i64 addrspace(1)* @"some_call"(i64 addrspace(1)* %ret_val1)
46 to label %normal_return unwind label %exceptional_return
47
48 ; CHECK-LABEL: normal_return:
49 normal_return:
50 ; CHECK: gc.result
51 ; CHECK: ret i64
52 ret i64 addrspace(1)* %ret_val2
53
54 ; CHECK: exceptional_return:
55 ; CHECK: ret i64
56
57 exceptional_return:
58 %landing_pad4 = landingpad {i8*, i32} personality i32 ()* @"personality_function"
59 cleanup
60 ret i64 addrspace(1)* %obj1
61 }
62
63 define i64 addrspace(1)* @test_phi_node(i1 %cond, i64 addrspace(1)* %obj) {
64 ; CHECK-LABEL: entry:
65 entry:
66 br i1 %cond, label %left, label %right
67
68 left:
69 %ret_val_left = invoke i64 addrspace(1)* @"some_call"(i64 addrspace(1)* %obj)
70 to label %merge unwind label %exceptional_return
71
72 right:
73 %ret_val_right = invoke i64 addrspace(1)* @"some_call"(i64 addrspace(1)* %obj)
74 to label %merge unwind label %exceptional_return
75
76 ; CHECK-LABEL: merge1:
77 ; CHECK: gc.result
78 ; CHECK: br label %merge
79
80 ; CHECK-LABEL: merge3:
81 ; CHECK: gc.result
82 ; CHECK: br label %merge
83
84 ; CHECK-LABEL: merge:
85 ; CHECK: phi
86 ; CHECK: ret i64 addrspace(1)* %ret_val
87 merge:
88 %ret_val = phi i64 addrspace(1)* [%ret_val_left, %left], [%ret_val_right, %right]
89 ret i64 addrspace(1)* %ret_val
90
91 ; CHECK-LABEL: exceptional_return:
92 ; CHECK: ret i64 addrspace(1)*
93
94 exceptional_return:
95 %landing_pad4 = landingpad {i8*, i32} personality i32 ()* @"personality_function"
96 cleanup
97 ret i64 addrspace(1)* %obj
98 }
99
100 declare void @do_safepoint()
101 define void @gc.safepoint_poll() {
102 ; CHECK-LABEL: gc.safepoint_poll
103 ; CHECK-LABEL: entry
104 ; CHECK-NEXT: do_safepoint
105 ; CHECK-NEXT: ret void
106 entry:
107 call void @do_safepoint()
108 ret void
109 }