llvm.org GIT mirror llvm / d3f3d5f
Introduce more tests for PlaceSafepoints These tests the two optimizations for backedge insertion currently implemented and the split backedge flag which is currently off by default. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228617 91177308-0d34-0410-b5e6-96231b3b80d8 Philip Reames 4 years ago
3 changed file(s) with 157 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 ; If there's a call in the loop which dominates the backedge, we
1 ; don't need a safepoint poll (since the callee must contain a
2 ; poll test).
3 ;; RUN: opt %s -place-safepoints -S | FileCheck %s
4
5 declare void @foo()
6
7 define void @test1() {
8 ; CHECK-LABEL: test1
9
10 entry:
11 ; CHECK-LABEL: entry
12 ; CHECK: statepoint
13 br label %loop
14
15 loop:
16 ; CHECK-LABEL: loop
17 ; CHECK: @llvm.experimental.gc.statepoint.p0f_isVoidf(void ()* @foo
18 ; CHECK-NOT: statepoint
19 call void @foo()
20 br label %loop
21 }
22
23 ; This function is inlined when inserting a poll.
24 declare void @do_safepoint()
25 define void @gc.safepoint_poll() {
26 ; CHECK-LABEL: gc.safepoint_poll
27 entry:
28 call void @do_safepoint()
29 ret void
30 }
0 ; Tests to ensure that we are not placing backedge safepoints in
1 ; loops which are clearly finite.
2 ;; RUN: opt %s -place-safepoints -S | FileCheck %s
3
4
5 ; A simple counted loop with trivially known range
6 define void @test1(i32) {
7 ; CHECK-LABEL: test1
8 ; CHECK-LABEL: entry
9 ; CHECK: statepoint
10 ; CHECK-LABEL: loop
11 ; CHECK-NOT: statepoint
12
13 entry:
14 br label %loop
15
16 loop:
17 %counter = phi i32 [ 0 , %entry ], [ %counter.inc , %loop ]
18 %counter.inc = add i32 %counter, 1
19 %counter.cmp = icmp slt i32 %counter.inc, 16
20 br i1 %counter.cmp, label %loop, label %exit
21
22 exit:
23 ret void
24 }
25
26 ; The same counted loop, but with an unknown early exit
27 define void @test2(i32) {
28 ; CHECK-LABEL: test2
29 ; CHECK-LABEL: entry
30 ; CHECK: statepoint
31 ; CHECK-LABEL: loop
32 ; CHECK-NOT: statepoint
33
34 entry:
35 br label %loop
36
37 loop:
38 %counter = phi i32 [ 0 , %entry ], [ %counter.inc , %continue ]
39 %counter.inc = add i32 %counter, 1
40 %counter.cmp = icmp slt i32 %counter.inc, 16
41 br i1 undef, label %continue, label %exit
42
43 continue:
44 br i1 %counter.cmp, label %loop, label %exit
45
46 exit:
47 ret void
48 }
49
50 ; The range is a 8 bit value and we can't overflow
51 define void @test3(i8 %upper) {
52 ; CHECK-LABEL: test3
53 ; CHECK-LABEL: entry
54 ; CHECK: statepoint
55 ; CHECK-LABEL: loop
56 ; CHECK-NOT: statepoint
57
58 entry:
59 br label %loop
60
61 loop:
62 %counter = phi i8 [ 0 , %entry ], [ %counter.inc , %loop ]
63 %counter.inc = add nsw i8 %counter, 1
64 %counter.cmp = icmp slt i8 %counter.inc, %upper
65 br i1 %counter.cmp, label %loop, label %exit
66
67 exit:
68 ret void
69 }
70
71
72 ; This function is inlined when inserting a poll.
73 declare void @do_safepoint()
74 define void @gc.safepoint_poll() {
75 ; CHECK-LABEL: gc.safepoint_poll
76 entry:
77 call void @do_safepoint()
78 ret void
79 }
0 ;; A very basic test to make sure that splitting the backedge keeps working
1 ;; RUN: opt -place-safepoints -spp-split-backedge=1 -S %s | FileCheck %s
2
3 define void @test(i32, i1 %cond) {
4 ; CHECK-LABEL: @test
5 ; CHECK-LABEL: loop.loop_crit_edge
6 ; CHECK: gc.statepoint
7 ; CHECK-NEXT: br label %loop
8 entry:
9 br label %loop
10
11 loop:
12 br i1 %cond, label %loop, label %exit
13
14 exit:
15 ret void
16 }
17
18 ; Test for the case where a single conditional branch jumps to two
19 ; different loop header blocks. Since we're currently using LoopSimplfy
20 ; this doesn't hit the interesting case, but once we remove that, we need
21 ; to be sure this keeps working.
22 define void @test2(i32, i1 %cond) {
23 ; CHECK-LABEL: @test2
24 ; CHECK-LABE: loop.loopexit.split
25 ; CHECK: gc.statepoint
26 ; CHECK-NEXT: br label %loop
27 ; CHECK-LABEL: loop2.loop2_crit_edge
28 ; CHECK: gc.statepoint
29 ; CHECK-NEXT: br label %loop2
30 entry:
31 br label %loop
32
33 loop:
34 br label %loop2
35
36 loop2:
37 br i1 %cond, label %loop, label %loop2
38 }
39
40 declare void @do_safepoint()
41 define void @gc.safepoint_poll() {
42 entry:
43 call void @do_safepoint()
44 ret void
45 }