1; Tests to ensure that we are not placing backedge safepoints in 2; loops which are clearly finite. 3;; RUN: opt %s -place-safepoints -S | FileCheck %s 4 5 6; A simple counted loop with trivially known range 7define void @test1(i32) gc "statepoint-example" { 8; CHECK-LABEL: test1 9; CHECK-LABEL: entry 10; CHECK: statepoint 11; CHECK-LABEL: loop 12; CHECK-NOT: statepoint 13 14entry: 15 br label %loop 16 17loop: 18 %counter = phi i32 [ 0 , %entry ], [ %counter.inc , %loop ] 19 %counter.inc = add i32 %counter, 1 20 %counter.cmp = icmp slt i32 %counter.inc, 16 21 br i1 %counter.cmp, label %loop, label %exit 22 23exit: 24 ret void 25} 26 27; The same counted loop, but with an unknown early exit 28define void @test2(i32) gc "statepoint-example" { 29; CHECK-LABEL: test2 30; CHECK-LABEL: entry 31; CHECK: statepoint 32; CHECK-LABEL: loop 33; CHECK-NOT: statepoint 34 35entry: 36 br label %loop 37 38loop: 39 %counter = phi i32 [ 0 , %entry ], [ %counter.inc , %continue ] 40 %counter.inc = add i32 %counter, 1 41 %counter.cmp = icmp slt i32 %counter.inc, 16 42 br i1 undef, label %continue, label %exit 43 44continue: 45 br i1 %counter.cmp, label %loop, label %exit 46 47exit: 48 ret void 49} 50 51; The range is a 8 bit value and we can't overflow 52define void @test3(i8 %upper) gc "statepoint-example" { 53; CHECK-LABEL: test3 54; CHECK-LABEL: entry 55; CHECK: statepoint 56; CHECK-LABEL: loop 57; CHECK-NOT: statepoint 58 59entry: 60 br label %loop 61 62loop: 63 %counter = phi i8 [ 0 , %entry ], [ %counter.inc , %loop ] 64 %counter.inc = add nsw i8 %counter, 1 65 %counter.cmp = icmp slt i8 %counter.inc, %upper 66 br i1 %counter.cmp, label %loop, label %exit 67 68exit: 69 ret void 70} 71 72 73; This function is inlined when inserting a poll. 74declare void @do_safepoint() 75define void @gc.safepoint_poll() { 76; CHECK-LABEL: gc.safepoint_poll 77entry: 78 call void @do_safepoint() 79 ret void 80} 81