a21066a51576a9046f7e1ed0722334e50da2382a
[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   call void @foo()
56   ret void
57 }
58
59
60 ; This function is inlined when inserting a poll.  To avoid recursive 
61 ; issues, make sure we don't place safepoints in it.
62 declare void @do_safepoint()
63 define void @gc.safepoint_poll() {
64 ; CHECK-LABEL: gc.safepoint_poll
65 ; CHECK-LABEL: entry
66 ; CHECK-NEXT: do_safepoint
67 ; CHECK-NEXT: ret void 
68 entry:
69   call void @do_safepoint()
70   ret void
71 }