|
7 | 7 |
|
8 | 8 | // REQUIRES: swift_stdlib_no_asserts, optimized_stdlib |
9 | 9 |
|
| 10 | +// CHECK-SIL-LABEL: sil @$s31mutable_span_bounds_check_tests0a1_B11_sum_w_trapySis11MutableSpanVySiGF : |
| 11 | +// CHECK-SIL: bb3({{.*}}): |
| 12 | +// CHECK-SIL-NOT: cond_fail {{.*}}, "index out of bounds" |
| 13 | +// CHECK-SIL-LABEL: } // end sil function '$s31mutable_span_bounds_check_tests0a1_B11_sum_w_trapySis11MutableSpanVySiGF' |
| 14 | +public func mutable_span_sum_w_trap(_ ms: borrowing MutableSpan<Int>) -> Int { |
| 15 | + var sum = 0 |
| 16 | + for i in ms.indices { |
| 17 | + sum += ms[i] |
| 18 | + } |
| 19 | + return sum |
| 20 | +} |
| 21 | + |
| 22 | +// CHECK-SIL-LABEL: sil @$s31mutable_span_bounds_check_tests0a1_B12_sum_wo_trapySis11MutableSpanVySiGF : |
| 23 | +// CHECK-SIL: bb3({{.*}}): |
| 24 | +// CHECK-SIL-NOT: cond_fail {{.*}}, "index out of bounds" |
| 25 | +// CHECK-SIL-LABEL: } // end sil function '$s31mutable_span_bounds_check_tests0a1_B12_sum_wo_trapySis11MutableSpanVySiGF' |
| 26 | +public func mutable_span_sum_wo_trap(_ ms: borrowing MutableSpan<Int>) -> Int { |
| 27 | + var sum = 0 |
| 28 | + for i in ms.indices { |
| 29 | + sum &+= ms[i] |
| 30 | + } |
| 31 | + return sum |
| 32 | +} |
| 33 | + |
| 34 | +// CHECK-SIL-LABEL: sil @$s31mutable_span_bounds_check_tests0a1_B25_sum_w_trap_unknown_boundySis11MutableSpanVySiG_SitF : |
| 35 | +// CHECK-SIL: bb3({{.*}}): |
| 36 | +// CHECK-SIL-NOT: cond_fail {{.*}}, "index out of bounds" |
| 37 | +// CHECK-SIL-LABEL: } // end sil function '$s31mutable_span_bounds_check_tests0a1_B25_sum_w_trap_unknown_boundySis11MutableSpanVySiG_SitF' |
| 38 | +public func mutable_span_sum_w_trap_unknown_bound(_ ms: borrowing MutableSpan<Int>, _ n: Int) -> Int { |
| 39 | + var sum = 0 |
| 40 | + for i in 0...n { |
| 41 | + sum += ms[i] |
| 42 | + } |
| 43 | + return sum |
| 44 | +} |
| 45 | + |
| 46 | +// CHECK-SIL-LABEL: sil @$s31mutable_span_bounds_check_tests0a1_B26_sum_wo_trap_unknown_boundySis11MutableSpanVySiG_SitF : |
| 47 | +// CHECK-SIL: bb3({{.*}}): |
| 48 | +// CHECK-SIL-NOT: cond_fail {{.*}}, "index out of bounds" |
| 49 | +// CHECK-SIL-LABEL: } // end sil function '$s31mutable_span_bounds_check_tests0a1_B26_sum_wo_trap_unknown_boundySis11MutableSpanVySiG_SitF' |
| 50 | +public func mutable_span_sum_wo_trap_unknown_bound(_ ms: borrowing MutableSpan<Int>, _ n: Int) -> Int { |
| 51 | + var sum = 0 |
| 52 | + for i in 0...n { |
| 53 | + sum &+= ms[i] |
| 54 | + } |
| 55 | + return sum |
| 56 | +} |
| 57 | + |
10 | 58 | // CHECK-SIL-LABEL: sil @$s31mutable_span_bounds_check_tests0B10_zero_inityys11MutableSpanVySiGzF : |
11 | 59 | // CHECK-SIL: bb3({{.*}}): |
12 | 60 | // CHECK-SIL: cond_fail {{.*}}, "index out of bounds" |
|
0 commit comments