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