1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py 2; RUN: opt < %s -passes=rewrite-statepoints-for-gc -S | FileCheck %s 3 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 8;; call statepoint. 9 10declare i32 @foo() 11 12define i32 @test1(i1 %cond, i32 %a) gc "statepoint-example" { 13; CHECK-LABEL: @test1( 14; CHECK-NEXT: entry: 15; CHECK-NEXT: br i1 [[COND:%.*]], label [[BRANCH1:%.*]], label [[BRANCH2:%.*]] 16; CHECK: branch1: 17; CHECK-NEXT: [[B:%.*]] = add i32 [[A:%.*]], 1 18; CHECK-NEXT: br label [[MERGE:%.*]] 19; CHECK: branch2: 20; CHECK-NEXT: br label [[MERGE]] 21; CHECK: 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]] 26; 27entry: 28 br i1 %cond, label %branch1, label %branch2 29 30branch1: 31 %b = add i32 %a, 1 32 br label %merge 33 34branch2: 35 br label %merge 36 37merge: 38 %phi = phi i32 [ %a, %branch2 ], [ %b, %branch1 ] 39 %ret = call i32 @foo() 40 ret i32 %ret 41} 42 43; This function is inlined when inserting a poll. 44declare void @do_safepoint() 45define void @gc.safepoint_poll() { 46; CHECK-LABEL: @gc.safepoint_poll( 47; CHECK-NEXT: entry: 48; CHECK-NEXT: call void @do_safepoint() 49; CHECK-NEXT: ret void 50; 51entry: 52 call void @do_safepoint() 53 ret void 54} 55