1; RUN: opt -rewrite-statepoints-for-gc -S < %s | FileCheck %s 2 3; A null test of a single value 4define i1 @test(i8 addrspace(1)* %p, i1 %rare) gc "statepoint-example" { 5; CHECK-LABEL: @test 6entry: 7 %cond = icmp eq i8 addrspace(1)* %p, null 8 br i1 %rare, label %safepoint, label %continue, !prof !0 9safepoint: 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 12continue: 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 20taken: 21 ret i1 true 22untaken: 23 ret i1 false 24} 25 26; Comparing two pointers 27define i1 @test2(i8 addrspace(1)* %p, i8 addrspace(1)* %q, i1 %rare) 28 gc "statepoint-example" { 29; CHECK-LABEL: @test2 30entry: 31 %cond = icmp eq i8 addrspace(1)* %p, %q 32 br i1 %rare, label %safepoint, label %continue, !prof !0 33safepoint: 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 36continue: 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 47taken: 48 ret i1 true 49untaken: 50 ret i1 false 51} 52 53; Sanity check that nothing bad happens if already last instruction 54; before terminator 55define i1 @test3(i8 addrspace(1)* %p, i8 addrspace(1)* %q, i1 %rare) 56 gc "statepoint-example" { 57; CHECK-LABEL: @test3 58entry: 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 65taken: 66 ret i1 true 67untaken: 68 ret i1 false 69} 70 71declare void @safepoint() 72declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...) 73 74!0 = !{!"branch_weights", i32 1, i32 10000} 75