@@ -28,7 +28,7 @@ public func span_sum_iterate_to_count_wo_trap(_ v: Span<Int>) -> Int {
2828 for i in 0 ..< v. count {
2929 sum &+= v [ i]
3030 }
31- return sum
31+ return sum &+ 1 // adding 1 to avoid LLVM function merging
3232}
3333
3434// Bounds check should be eliminated
@@ -175,15 +175,10 @@ public func span_sum_iterate_to_deducible_count2_with_trap(_ v: Span<Int>, _ n:
175175}
176176
177177// Bounds check should be eliminated
178- // SIL optimizer hoists bounds checks from the loop
178+ // TODO: there should not be any cond_fail in this function
179179
180180// CHECK-SIL-LABEL: sil @$s23span_bounds_check_tests0A29_iterate_over_indices_wo_trapySis4SpanVySiGF :
181- // CHECK-SIL: bb1
182- // CHECK-SIL: cond_fail {{.*}}, "Index out of bounds"
183- // CHECK-SIL: cond_fail {{.*}}, "Index out of bounds"
184- // CHECK-SIL: bb3
185181// CHECK-SIL-NOT: cond_fail {{.*}}, "Index out of bounds"
186- // CHECK-SIL: cond_br
187182// CHECK-SIL-LABEL: } // end sil function '$s23span_bounds_check_tests0A29_iterate_over_indices_wo_trapySis4SpanVySiGF'
188183
189184// CHECK-IR: define {{.*}} @"$s23span_bounds_check_tests0A29_iterate_over_indices_wo_trapySis4SpanVySiGF"
@@ -200,12 +195,7 @@ public func span_iterate_over_indices_wo_trap(_ v: Span<Int>) -> Int {
200195// SIL optimizer hoists bounds checks from the loop
201196
202197// CHECK-SIL-LABEL: sil @$s23span_bounds_check_tests0A31_iterate_over_indices_with_trapySis4SpanVySiGF :
203- // CHECK-SIL: bb1
204- // CHECK-SIL: cond_fail {{.*}}, "Index out of bounds"
205- // CHECK-SIL: cond_fail {{.*}}, "Index out of bounds"
206- // CHECK-SIL: bb3
207198// CHECK-SIL-NOT: cond_fail {{.*}}, "Index out of bounds"
208- // CHECK-SIL: cond_br
209199// CHECK-SIL-LABEL: } // end sil function '$s23span_bounds_check_tests0A31_iterate_over_indices_with_trapySis4SpanVySiGF'
210200public func span_iterate_over_indices_with_trap( _ v: Span < Int > ) -> Int {
211201 var sum = 0
@@ -254,12 +244,11 @@ public func span_search<T : Equatable>(_ v: Span<T>, _ elem: T) -> Int? {
254244 return nil
255245}
256246
257- // Bounds check should be eliminated
247+ // TODO: Bounds check should be eliminated
258248
259249// CHECK-SIL-LABEL: sil @$s23span_bounds_check_tests0A11_search_splySiSgs4SpanVySiG_SitF :
260250// CHECK-SIL: bb3:
261251// CHECK-SIL: cond_fail {{.*}}, "Index out of bounds"
262- // CHECK-SIL: cond_fail {{.*}}, "Index out of bounds"
263252// CHECK-SIL: cond_br
264253// CHECK-SIL-LABEL: } // end sil function '$s23span_bounds_check_tests0A11_search_splySiSgs4SpanVySiG_SitF'
265254public func span_search_spl( _ v: Span < Int > , _ elem: Int ) -> Int ? {
0 commit comments