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: call void @do_safepoint 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: do_safepoint 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: call void @do_safepoint 29 br label %other 30 31; CHECK-LABEL: other 32; CHECK: call void @do_safepoint 33other: 34 br label %other 35} 36 37; Check that we remove an unreachable block rather than trying 38; to insert a backedge safepoint 39define void @test_unreachable() gc "statepoint-example" { 40; CHECK-LABEL: test_unreachable 41entry: 42; CHECK-LABEL: entry 43; CHECK: call void @do_safepoint 44 ret void 45 46; CHECK-NOT: other 47; CHECK-NOT: do_safepoint 48other: 49 br label %other 50} 51 52declare void @foo() 53 54declare zeroext i1 @i1_return_i1(i1) 55 56define i1 @test_call_with_result() gc "statepoint-example" { 57; CHECK-LABEL: test_call_with_result 58; This is checking that a statepoint_poll is inserted for a function 59; that takes 1 argument. 60; CHECK: call void @do_safepoint 61entry: 62 %call1 = tail call i1 (i1) @i1_return_i1(i1 false) 63 ret i1 %call1 64} 65 66; This function is inlined when inserting a poll. To avoid recursive 67; issues, make sure we don't place safepoints in it. 68declare void @do_safepoint() 69define void @gc.safepoint_poll() { 70; CHECK-LABEL: gc.safepoint_poll 71; CHECK-LABEL: entry 72; CHECK-NEXT: do_safepoint 73; CHECK-NEXT: ret void 74entry: 75 call void @do_safepoint() 76 ret void 77} 78