PlaceSafepoints: modernize gc.result.* -> gc.result
[oota-llvm.git] / test / Transforms / PlaceSafepoints / basic.ll
1 ; RUN: opt %s -S -place-safepoints | FileCheck %s
2
3
4 ; Do we insert a simple entry safepoint?
5 define void @test_entry() gc "statepoint-example" {
6 ; CHECK-LABEL: @test_entry
7 entry:
8 ; CHECK-LABEL: entry
9 ; CHECK: statepoint
10   ret void
11 }
12
13 ; Do we insert a backedge safepoint in a statically
14 ; infinite loop?
15 define void @test_backedge() gc "statepoint-example" {
16 ; CHECK-LABEL: test_backedge
17 entry:
18 ; CHECK-LABEL: entry
19 ; This statepoint is technically not required, but we don't exploit that yet.
20 ; CHECK: statepoint
21   br label %other
22
23 ; CHECK-LABEL: other
24 ; CHECK: statepoint
25 other:
26   call void undef()
27   br label %other
28 }
29
30 ; Check that we remove an unreachable block rather than trying
31 ; to insert a backedge safepoint
32 define void @test_unreachable() gc "statepoint-example" {
33 ; CHECK-LABEL: test_unreachable
34 entry:
35 ; CHECK-LABEL: entry
36 ; CHECK: statepoint
37   ret void
38
39 ; CHECK-NOT: other
40 ; CHECK-NOT: statepoint
41 other:
42   br label %other
43 }
44
45 declare void @foo()
46
47 ; Do we turn a call into it's own statepoint
48 define void @test_simple_call() gc "statepoint-example" {
49 ; CHECK-LABEL: test_simple_call
50 entry:
51   br label %other
52 other:
53 ; CHECK-LABEL: other
54 ; CHECK: statepoint
55 ; CHECK-NOT: gc.result
56   call void @foo()
57   ret void
58 }
59
60 declare zeroext i1 @i1_return_i1(i1)
61
62 define i1 @test_call_with_result() gc "statepoint-example" {
63 ; CHECK-LABEL: test_call_with_result
64 ; This is checking that a statepoint_poll + statepoint + result is
65 ; inserted for a function that takes 1 argument.
66 ; CHECK: gc.statepoint.p0f_isVoidf
67 ; CHECK: gc.statepoint.p0f_i1i1f
68 ; CHECK: (i1 (i1)* @i1_return_i1, i32 1, i32 0, i1 false, i32 0)
69 ; CHECK: gc.result.i1
70 entry:
71   %call1 = tail call i1 (i1)* @i1_return_i1(i1 false)
72   ret i1 %call1
73 }
74
75 ; This function is inlined when inserting a poll.  To avoid recursive 
76 ; issues, make sure we don't place safepoints in it.
77 declare void @do_safepoint()
78 define void @gc.safepoint_poll() {
79 ; CHECK-LABEL: gc.safepoint_poll
80 ; CHECK-LABEL: entry
81 ; CHECK-NEXT: do_safepoint
82 ; CHECK-NEXT: ret void 
83 entry:
84   call void @do_safepoint()
85   ret void
86 }