1 ;; RUN: opt < %s -rewrite-statepoints-for-gc -S | FileCheck %s 2 3 ;; This test is to verify that gc_result from a call statepoint 4 ;; can have preceding phis in its parent basic block. Unlike 5 ;; invoke statepoint, call statepoint does not terminate the 6 ;; block, and thus its gc_result is in the same block with the 7 ;; call statepoint. 8 9 declare i32 @foo() 10 11 define i32 @test1(i1 %cond, i32 %a) gc "statepoint-example" { 12 entry: 13 br i1 %cond, label %branch1, label %branch2 14 15 branch1: 16 %b = add i32 %a, 1 17 br label %merge 18 19 branch2: 20 br label %merge 21 22 merge: 23 ;; CHECK: %phi = phi i32 [ %a, %branch2 ], [ %b, %branch1 ] 24 ;; CHECK-NEXT: [[TOKEN:%[^ ]+]] = call token (i64, i32, i32 ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_i32f(i64 2882400000, i32 0, i32 ()* @foo, i32 0, i32 0, i32 0, i32 0 25 ;; CHECK-NEXT: call i32 @llvm.experimental.gc.result.i32(token [[TOKEN]]) 26 %phi = phi i32 [ %a, %branch2 ], [ %b, %branch1 ] 27 %ret = call i32 @foo() 28 ret i32 %ret 29 } 30 31 ; This function is inlined when inserting a poll. 32 declare void @do_safepoint() 33 define void @gc.safepoint_poll() { 34 ; CHECK-LABEL: gc.safepoint_poll 35 entry: 36 call void @do_safepoint() 37 ret void 38 } 39