1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -passes=rewrite-statepoints-for-gc -S | FileCheck %s
4 ;; This test is to verify that gc_result from a call statepoint
5 ;; can have preceding phis in its parent basic block. Unlike
6 ;; invoke statepoint, call statepoint does not terminate the
7 ;; block, and thus its gc_result is in the same block with the
12 define i32 @test1(i1 %cond, i32 %a) gc "statepoint-example" {
13 ; CHECK-LABEL: @test1(
15 ; CHECK-NEXT: br i1 [[COND:%.*]], label [[BRANCH1:%.*]], label [[BRANCH2:%.*]]
17 ; CHECK-NEXT: [[B:%.*]] = add i32 [[A:%.*]], 1
18 ; CHECK-NEXT: br label [[MERGE:%.*]]
20 ; CHECK-NEXT: br label [[MERGE]]
22 ; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ [[A]], [[BRANCH2]] ], [ [[B]], [[BRANCH1]] ]
23 ; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, ptr, i32, i32, ...) @llvm.experimental.gc.statepoint.p0(i64 2882400000, i32 0, ptr elementtype(i32 ()) @foo, i32 0, i32 0, i32 0, i32 0)
24 ; CHECK-NEXT: [[RET1:%.*]] = call i32 @llvm.experimental.gc.result.i32(token [[STATEPOINT_TOKEN]])
25 ; CHECK-NEXT: ret i32 [[RET1]]
28 br i1 %cond, label %branch1, label %branch2
38 %phi = phi i32 [ %a, %branch2 ], [ %b, %branch1 ]
39 %ret = call i32 @foo()
43 ; This function is inlined when inserting a poll.
44 declare void @do_safepoint()
45 define void @gc.safepoint_poll() {
46 ; CHECK-LABEL: @gc.safepoint_poll(
48 ; CHECK-NEXT: call void @do_safepoint()
49 ; CHECK-NEXT: ret void
52 call void @do_safepoint()