11// RUN: %empty-directory(%t)
2- // RUN: %target-swift-frontend -I %t -O -emit-sil %s -enable-experimental-feature Lifetimes -disable-availability-checking | %FileCheck %s --check-prefix=CHECK-SIL
2+ // RUN: %target-swift-frontend -I %t -O -emit-sil %s -enable-experimental-feature Lifetimes -disable-availability-checking | %FileCheck %s --check-prefix=CHECK-SIL
33// RUN: %target-swift-frontend -I %t -O -emit-ir %s -enable-experimental-feature Lifetimes -disable-availability-checking | %FileCheck %s --check-prefix=CHECK-IR
44
55// REQUIRES: swift_in_compiler
66// REQUIRES: swift_feature_Lifetimes
77
88// REQUIRES: swift_stdlib_no_asserts, optimized_stdlib
99
10- // Bounds check should be eliminated
11- // SIL removes lower bounds check
12- // LLVM removes upper bounds check and vectorizes the loop
13-
14- // CHECK-SIL-LABEL: sil @$s31mutable_span_bounds_check_tests0B10_zero_inityy10SpanExtras07MutableH0VySiGzF :
10+ // CHECK-SIL-LABEL: sil @$s31mutable_span_bounds_check_tests0B10_zero_inityys11MutableSpanVySiGzF :
1511// CHECK-SIL: bb3({{.*}}):
16- // CHECK-SIL: cond_fail {{.*}}, "precondition failure "
17- // CHECK-SIL-NOT: cond_fail {{.*}}, "precondition failure "
12+ // CHECK-SIL: cond_fail {{.*}}, "index out of bounds "
13+ // CHECK-SIL-NOT: cond_fail {{.*}}, "index out of bounds "
1814// CHECK-SIL: cond_br
19- // CHECK-SIL-LABEL: } // end sil function '$s31mutable_span_bounds_check_tests0B10_zero_inityy10SpanExtras07MutableH0VySiGzF '
15+ // CHECK-SIL-LABEL: } // end sil function '$s31mutable_span_bounds_check_tests0B10_zero_inityys11MutableSpanVySiGzF '
2016
21- // CHECK-IR: define {{.*}} void @"$s31mutable_span_bounds_check_tests0B10_zero_inityy10SpanExtras07MutableH0VySiGzF "
17+ // CHECK-IR: define {{.*}} void @"$s31mutable_span_bounds_check_tests0B10_zero_inityys11MutableSpanVySiGzF "
2218// CHECK-IR: vector.body
2319// CHECK-IR: store <{{.*}}> zeroinitializer,
2420public func span_zero_init( _ output: inout MutableSpan < Int > ) {
@@ -27,18 +23,14 @@ public func span_zero_init(_ output: inout MutableSpan<Int>) {
2723 }
2824}
2925
30- // Bounds check should be eliminated
31- // SIL removes lower bounds check
32- // LLVM removes upper bounds check and vectorizes the loop
33-
34- // CHECK-SIL-LABEL: sil @$s31mutable_span_bounds_check_tests0B14_copy_elemwiseyy10SpanExtras07MutableH0VySiGz_s0H0VySiGtF :
26+ // CHECK-SIL-LABEL: sil @$s31mutable_span_bounds_check_tests0B14_copy_elemwiseyys11MutableSpanVySiGz_s0I0VySiGtF :
3527// CHECK-SIL: bb3({{.*}}):
36- // CHECK-SIL: cond_fail {{.*}}, "precondition failure "
37- // CHECK-SIL-NOT: cond_fail {{.*}}, "precondition failure "
28+ // CHECK-SIL: cond_fail {{.*}}, "index out of bounds "
29+ // CHECK-SIL-NOT: cond_fail {{.*}}, "index out of bounds "
3830// CHECK-SIL: cond_br
39- // CHECK-SIL-LABEL: } // end sil function '$s31mutable_span_bounds_check_tests0B14_copy_elemwiseyy10SpanExtras07MutableH0VySiGz_s0H0VySiGtF '
31+ // CHECK-SIL-LABEL: } // end sil function '$s31mutable_span_bounds_check_tests0B14_copy_elemwiseyys11MutableSpanVySiGz_s0I0VySiGtF '
4032
41- // CHECK-IR: define {{.*}} void @"$s31mutable_span_bounds_check_tests0B14_copy_elemwiseyy10SpanExtras07MutableH0VySiGz_s0H0VySiGtF "
33+ // CHECK-IR: define {{.*}} void @"$s31mutable_span_bounds_check_tests0B14_copy_elemwiseyys11MutableSpanVySiGz_s0I0VySiGtF "
4234// CHECK-IR: vector.body
4335// CHECK-IR: store <{{.*}}>
4436@_lifetime ( output: copy output, copy input)
@@ -49,18 +41,14 @@ public func span_copy_elemwise(_ output: inout MutableSpan<Int>, _ input: Span<I
4941 }
5042}
5143
52- // Bounds check should be eliminated
53- // SIL removes lower bounds check
54- // LLVM removes upper bounds check and vectorizes the loop
44+ // CHECK-SIL-LABEL: sil @$s31mutable_span_bounds_check_tests0B16_append_elemwiseyys10OutputSpanVySiGz_s0I0VySiGtF :
45+ // FIX-CHECK-SIL: bb3({{.*}}):
46+ // FIX-CHECK-SIL: cond_fail {{.*}}, "index out of bounds"
47+ // FIX-CHECK-SIL-NOT: cond_fail {{.*}}, "index out of bounds"
48+ // FIX-CHECK-SIL: cond_br
49+ // CHECK-SIL-LABEL: } // end sil function '$s31mutable_span_bounds_check_tests0B16_append_elemwiseyys10OutputSpanVySiGz_s0I0VySiGtF'
5550
56- // CHECK-SIL-LABEL: sil @$s31mutable_span_bounds_check_tests0B16_append_elemwiseyy10SpanExtras06OutputH0VySiGz_s0H0VySiGtF :
57- // CHECK-SIL: bb3({{.*}}):
58- // CHECK-SIL: cond_fail {{.*}}, "precondition failure"
59- // CHECK-SIL-NOT: cond_fail {{.*}}, "precondition failure"
60- // CHECK-SIL: cond_br
61- // CHECK-SIL-LABEL: } // end sil function '$s31mutable_span_bounds_check_tests0B16_append_elemwiseyy10SpanExtras06OutputH0VySiGz_s0H0VySiGtF'
62-
63- // CHECK-IR: define {{.*}} void @"$s31mutable_span_bounds_check_tests0B16_append_elemwiseyy10SpanExtras06OutputH0VySiGz_s0H0VySiGtF"
51+ // CHECK-IR: define {{.*}} void @"$s31mutable_span_bounds_check_tests0B16_append_elemwiseyys10OutputSpanVySiGz_s0I0VySiGtF"
6452// CHECK-IR: vector.body
6553// CHECK-IR: store <{{.*}}>
6654@_lifetime ( output: copy output, copy input)
@@ -70,16 +58,14 @@ public func span_append_elemwise(_ output: inout OutputSpan<Int>, _ input: Span<
7058 }
7159}
7260
73- // Bounds check should be eliminated
74-
75- // CHECK-SIL-LABEL: sil @$s31mutable_span_bounds_check_tests0B12_sum_wo_trapyy10SpanExtras07MutableI0VySiGz_s0I0VySiGAItF :
61+ // CHECK-SIL-LABEL: sil @$s31mutable_span_bounds_check_tests0B12_sum_wo_trapyys11MutableSpanVySiGz_s0J0VySiGAHtF :
7662// CHECK-SIL: bb3({{.*}}):
77- // CHECK-SIL: cond_fail {{.*}}, "precondition failure "
78- // CHECK-SIL-NOT: cond_fail {{.*}}, "precondition failure "
63+ // CHECK-SIL: cond_fail {{.*}}, "index out of bounds "
64+ // CHECK-SIL-NOT: cond_fail {{.*}}, "index out of bounds "
7965// CHECK-SIL: cond_br
80- // CHECK-SIL-LABEL: } // end sil function '$s31mutable_span_bounds_check_tests0B12_sum_wo_trapyy10SpanExtras07MutableI0VySiGz_s0I0VySiGAItF '
66+ // CHECK-SIL-LABEL: } // end sil function '$s31mutable_span_bounds_check_tests0B12_sum_wo_trapyys11MutableSpanVySiGz_s0J0VySiGAHtF '
8167
82- // CHECK-IR: define {{.*}} void @"$s31mutable_span_bounds_check_tests0B12_sum_wo_trapyy10SpanExtras07MutableI0VySiGz_s0I0VySiGAItF "
68+ // CHECK-IR: define {{.*}} void @"$s31mutable_span_bounds_check_tests0B12_sum_wo_trapyys11MutableSpanVySiGz_s0J0VySiGAHtF "
8369// CHECK-IR: vector.body
8470// CHECK-IR: store <{{.*}}>
8571@_lifetime ( output: copy output, copy input1, copy input2)
@@ -91,12 +77,12 @@ public func span_sum_wo_trap(_ output: inout MutableSpan<Int>, _ input1: Span<In
9177 }
9278}
9379
94- // CHECK-SIL-LABEL: sil @$s31mutable_span_bounds_check_tests0B14_sum_with_trapyy10SpanExtras07MutableI0VySiGz_s0I0VySiGAItF :
80+ // CHECK-SIL-LABEL: sil @$s31mutable_span_bounds_check_tests0B14_sum_with_trapyys11MutableSpanVySiGz_s0J0VySiGAHtF :
9581// CHECK-SIL: bb3({{.*}}):
96- // CHECK-SIL: cond_fail {{.*}}, "precondition failure "
97- // CHECK-SIL-NOT: cond_fail {{.*}}, "precondition failure "
82+ // CHECK-SIL: cond_fail {{.*}}, "index out of bounds "
83+ // CHECK-SIL-NOT: cond_fail {{.*}}, "index out of bounds "
9884// CHECK-SIL: cond_br
99- // CHECK-SIL-LABEL: } // end sil function '$s31mutable_span_bounds_check_tests0B14_sum_with_trapyy10SpanExtras07MutableI0VySiGz_s0I0VySiGAItF '
85+ // CHECK-SIL-LABEL: } // end sil function '$s31mutable_span_bounds_check_tests0B14_sum_with_trapyys11MutableSpanVySiGz_s0J0VySiGAHtF '
10086@_lifetime ( output: copy input1 , copy input2)
10187public func span_sum_with_trap( _ output: inout MutableSpan < Int > , _ input1: Span < Int > , _ input2: Span < Int > ) {
10288 precondition ( input1. count == input2. count)
@@ -106,12 +92,10 @@ public func span_sum_with_trap(_ output: inout MutableSpan<Int>, _ input1: Span<
10692 }
10793}
10894
109- // CHECK-SIL-LABEL: sil @$s31mutable_span_bounds_check_tests0B12_bubble_sortyy10SpanExtras07MutableH0VySiGzF :
110- // CHECK-SIL: bb11({{.*}}):
111- // CHECK-SIL: cond_fail {{.*}}, "precondition failure"
112- // CHECK-SIL: cond_fail {{.*}}, "precondition failure"
113- // CHECK-SIL: cond_br
114- // CHECK-SIL-LABEL: } // end sil function '$s31mutable_span_bounds_check_tests0B12_bubble_sortyy10SpanExtras07MutableH0VySiGzF'
95+ // CHECK-SIL-LABEL: sil @$s31mutable_span_bounds_check_tests0B12_bubble_sortyys11MutableSpanVySiGzF :
96+ // CHECK-SIL: bb12{{.*}}:
97+ // CHECK-SIL-NOT: cond_fail {{.*}}, "index out of bounds"
98+ // CHECK-SIL-LABEL: } // end sil function '$s31mutable_span_bounds_check_tests0B12_bubble_sortyys11MutableSpanVySiGzF'
11599public func span_bubble_sort( _ span: inout MutableSpan < Int > ) {
116100 if span. count <= 1 {
117101 return
@@ -127,12 +111,12 @@ public func span_bubble_sort(_ span: inout MutableSpan<Int>) {
127111 }
128112}
129113
130- // CHECK-SIL-LABEL: sil @$s31mutable_span_bounds_check_tests6sortedySb10SpanExtras07MutableG0VySiGF :
114+ // CHECK-SIL-LABEL: sil @$s31mutable_span_bounds_check_tests6sortedySbs11MutableSpanVySiGF :
131115// CHECK-SIL: bb4:
132- // CHECK-SIL: cond_fail {{.*}}, "precondition failure "
133- // CHECK-SIL: cond_fail {{.*}}, "precondition failure "
116+ // CHECK-SIL: cond_fail {{.*}}, "index out of bounds "
117+ // CHECK-SIL: cond_fail {{.*}}, "index out of bounds "
134118// CHECK-SIL: cond_br
135- // CHECK-SIL-LABEL: } // end sil function '$s31mutable_span_bounds_check_tests6sortedySb10SpanExtras07MutableG0VySiGF '
119+ // CHECK-SIL-LABEL: } // end sil function '$s31mutable_span_bounds_check_tests6sortedySbs11MutableSpanVySiGF '
136120public func sorted( _ span: borrowing MutableSpan < Int > ) -> Bool {
137121 if span. count <= 1 {
138122 return true
0 commit comments