Eric Christopher | cee313d | 2019-04-17 04:52:47 +0000 | [diff] [blame] | 1 | ; RUN: opt -rewrite-statepoints-for-gc -S < %s | FileCheck %s |
| 2 | ; RUN: opt -passes=rewrite-statepoints-for-gc -S < %s | FileCheck %s |
| 3 | |
| 4 | ; A null test of a single value |
| 5 | |
| 6 | define i1 @test(i8 addrspace(1)* %p, i1 %rare) gc "statepoint-example" { |
| 7 | ; CHECK-LABEL: @test |
| 8 | entry: |
| 9 | %cond = icmp eq i8 addrspace(1)* %p, null |
| 10 | br i1 %rare, label %safepoint, label %continue, !prof !0 |
| 11 | |
| 12 | safepoint: ; preds = %entry |
| 13 | call void @safepoint() [ "deopt"() ] |
| 14 | br label %continue |
| 15 | |
| 16 | continue: ; preds = %safepoint, %entry |
| 17 | ; CHECK-LABEL: continue: |
| 18 | ; CHECK: phi |
| 19 | ; CHECK-DAG: [ %p.relocated, %safepoint ] |
| 20 | ; CHECK-DAG: [ %p, %entry ] |
| 21 | ; CHECK: %cond = icmp |
| 22 | ; CHECK: br i1 %cond |
| 23 | ; Comparing two pointers |
| 24 | br i1 %cond, label %taken, label %untaken |
| 25 | |
| 26 | taken: ; preds = %continue |
| 27 | ret i1 true |
| 28 | |
| 29 | untaken: ; preds = %continue |
| 30 | ret i1 false |
| 31 | } |
| 32 | |
| 33 | define i1 @test2(i8 addrspace(1)* %p, i8 addrspace(1)* %q, i1 %rare) gc "statepoint-example" { |
| 34 | ; CHECK-LABEL: @test2 |
| 35 | entry: |
| 36 | %cond = icmp eq i8 addrspace(1)* %p, %q |
| 37 | br i1 %rare, label %safepoint, label %continue, !prof !0 |
| 38 | |
| 39 | safepoint: ; preds = %entry |
| 40 | call void @safepoint() [ "deopt"() ] |
| 41 | br label %continue |
| 42 | |
| 43 | continue: ; preds = %safepoint, %entry |
| 44 | ; CHECK-LABEL: continue: |
| 45 | ; CHECK: phi |
| 46 | ; CHECK-DAG: [ %q.relocated, %safepoint ] |
| 47 | ; CHECK-DAG: [ %q, %entry ] |
| 48 | ; CHECK: phi |
| 49 | ; CHECK-DAG: [ %p.relocated, %safepoint ] |
| 50 | ; CHECK-DAG: [ %p, %entry ] |
| 51 | ; CHECK: %cond = icmp |
| 52 | ; CHECK: br i1 %cond |
| 53 | ; Sanity check that nothing bad happens if already last instruction |
| 54 | ; before terminator |
| 55 | br i1 %cond, label %taken, label %untaken |
| 56 | |
| 57 | taken: ; preds = %continue |
| 58 | ret i1 true |
| 59 | |
| 60 | untaken: ; preds = %continue |
| 61 | ret i1 false |
| 62 | } |
| 63 | |
| 64 | define i1 @test3(i8 addrspace(1)* %p, i8 addrspace(1)* %q, i1 %rare) gc "statepoint-example" { |
| 65 | ; CHECK-LABEL: @test3 |
| 66 | ; CHECK: gc.statepoint |
| 67 | ; CHECK: %cond = icmp |
| 68 | ; CHECK: br i1 %cond |
| 69 | entry: |
| 70 | call void @safepoint() [ "deopt"() ] |
| 71 | %cond = icmp eq i8 addrspace(1)* %p, %q |
| 72 | br i1 %cond, label %taken, label %untaken |
| 73 | |
| 74 | taken: ; preds = %entry |
| 75 | ret i1 true |
| 76 | |
| 77 | untaken: ; preds = %entry |
| 78 | ret i1 false |
| 79 | } |
| 80 | |
| 81 | declare void @safepoint() |
| 82 | !0 = !{!"branch_weights", i32 1, i32 10000} |