1; RUN: opt %s -S -place-safepoints | FileCheck %s 2 3 4; Do we insert a simple entry safepoint? 5define void @test_entry() gc "statepoint-example" { 6; CHECK-LABEL: @test_entry 7entry: 8; CHECK-LABEL: entry 9; CHECK: statepoint 10 ret void 11} 12 13; On a non-gc function, we should NOT get an entry safepoint 14define void @test_negative() { 15; CHECK-LABEL: @test_negative 16entry: 17; CHECK-NOT: statepoint 18 ret void 19} 20 21; Do we insert a backedge safepoint in a statically 22; infinite loop? 23define void @test_backedge() gc "statepoint-example" { 24; CHECK-LABEL: test_backedge 25entry: 26; CHECK-LABEL: entry 27; This statepoint is technically not required, but we don't exploit that yet. 28; CHECK: statepoint 29 br label %other 30 31; CHECK-LABEL: other 32; CHECK: statepoint 33other: 34 call void undef() 35 br label %other 36} 37 38; Check that we remove an unreachable block rather than trying 39; to insert a backedge safepoint 40define void @test_unreachable() gc "statepoint-example" { 41; CHECK-LABEL: test_unreachable 42entry: 43; CHECK-LABEL: entry 44; CHECK: statepoint 45 ret void 46 47; CHECK-NOT: other 48; CHECK-NOT: statepoint 49other: 50 br label %other 51} 52 53declare void @foo() 54 55; Do we turn a call into it's own statepoint 56define void @test_simple_call() gc "statepoint-example" { 57; CHECK-LABEL: test_simple_call 58entry: 59 br label %other 60other: 61; CHECK-LABEL: other 62; CHECK: statepoint 63; CHECK-NOT: gc.result 64 call void @foo() 65 ret void 66} 67 68declare zeroext i1 @i1_return_i1(i1) 69 70define i1 @test_call_with_result() gc "statepoint-example" { 71; CHECK-LABEL: test_call_with_result 72; This is checking that a statepoint_poll + statepoint + result is 73; inserted for a function that takes 1 argument. 74; CHECK: gc.statepoint.p0f_isVoidf 75; CHECK: gc.statepoint.p0f_i1i1f 76; CHECK: (i1 (i1)* @i1_return_i1, i32 1, i32 0, i1 false, i32 0) 77; CHECK: %call12 = call i1 @llvm.experimental.gc.result.i1 78entry: 79 %call1 = tail call i1 (i1) @i1_return_i1(i1 false) 80 ret i1 %call1 81} 82 83; This function is inlined when inserting a poll. To avoid recursive 84; issues, make sure we don't place safepoints in it. 85declare void @do_safepoint() 86define void @gc.safepoint_poll() { 87; CHECK-LABEL: gc.safepoint_poll 88; CHECK-LABEL: entry 89; CHECK-NEXT: do_safepoint 90; CHECK-NEXT: ret void 91entry: 92 call void @do_safepoint() 93 ret void 94} 95