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 6define i1 @test(i8 addrspace(1)* %p, i1 %rare) gc "statepoint-example" { 7; CHECK-LABEL: @test 8entry: 9 %cond = icmp eq i8 addrspace(1)* %p, null 10 br i1 %rare, label %safepoint, label %continue, !prof !0 11 12safepoint: ; preds = %entry 13 call void @safepoint() [ "deopt"() ] 14 br label %continue 15 16continue: ; 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 26taken: ; preds = %continue 27 ret i1 true 28 29untaken: ; preds = %continue 30 ret i1 false 31} 32 33define i1 @test2(i8 addrspace(1)* %p, i8 addrspace(1)* %q, i1 %rare) gc "statepoint-example" { 34; CHECK-LABEL: @test2 35entry: 36 %cond = icmp eq i8 addrspace(1)* %p, %q 37 br i1 %rare, label %safepoint, label %continue, !prof !0 38 39safepoint: ; preds = %entry 40 call void @safepoint() [ "deopt"() ] 41 br label %continue 42 43continue: ; 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 57taken: ; preds = %continue 58 ret i1 true 59 60untaken: ; preds = %continue 61 ret i1 false 62} 63 64define 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 69entry: 70 call void @safepoint() [ "deopt"() ] 71 %cond = icmp eq i8 addrspace(1)* %p, %q 72 br i1 %cond, label %taken, label %untaken 73 74taken: ; preds = %entry 75 ret i1 true 76 77untaken: ; preds = %entry 78 ret i1 false 79} 80 81declare void @safepoint() 82!0 = !{!"branch_weights", i32 1, i32 10000} 83