Add basic tests for PlaceSafepoints
[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(i8 addrspace(1)* %arg) {
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(i8 addrspace(1)* %arg) {
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   %tmp = bitcast i8 addrspace(1)* %arg to i32 addrspace(1)*
27   call void undef()
28   br label %other
29 }
30
31 ; Check that we remove an unreachable block rather than trying
32 ; to insert a backedge safepoint
33 define void @test_unreachable(i8 addrspace(1)* %arg) {
34 ; CHECK-LABEL: test_unreachable
35 entry:
36 ; CHECK-LABEL: entry
37 ; CHECK: statepoint
38   ret void
39
40 ; CHECK-NOT: other
41 ; CHECK-NOT: statepoint
42 other:
43   br label %other
44 }
45
46 declare void @foo()
47
48 ; Do we turn a call into it's own statepoint
49 define void @test_simple_call() {
50 ; CHECK-LABEL: test_simple_call
51 entry:
52   br label %other
53 other:
54 ; CHECK-LABEL: other
55 ; CHECK: statepoint 
56   call void @foo()
57   ret void
58 }
59
60
61 ; This function is inlined when inserting a poll.  To avoid recursive 
62 ; issues, make sure we don't place safepoints in it.
63 declare void @do_safepoint()
64 define void @gc.safepoint_poll() {
65 ; CHECK-LABEL: gc.safepoint_poll
66 ; CHECK-LABEL: entry
67 ; CHECK-NEXT: do_safepoint
68 ; CHECK-NEXT: ret void 
69 entry:
70   call void @do_safepoint()
71   ret void
72 }