@@ -28,7 +28,7 @@ public func span_sum_iterate_to_count_wo_trap(_ v: Span<Int>) -> Int {
28
28
for i in 0 ..< v. count {
29
29
sum &+= v [ i]
30
30
}
31
- return sum
31
+ return sum &+ 1 // adding 1 to avoid LLVM function merging
32
32
}
33
33
34
34
// Bounds check should be eliminated
@@ -175,15 +175,10 @@ public func span_sum_iterate_to_deducible_count2_with_trap(_ v: Span<Int>, _ n:
175
175
}
176
176
177
177
// 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
179
179
180
180
// 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
185
181
// CHECK-SIL-NOT: cond_fail {{.*}}, "Index out of bounds"
186
- // CHECK-SIL: cond_br
187
182
// CHECK-SIL-LABEL: } // end sil function '$s23span_bounds_check_tests0A29_iterate_over_indices_wo_trapySis4SpanVySiGF'
188
183
189
184
// 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 {
200
195
// SIL optimizer hoists bounds checks from the loop
201
196
202
197
// 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
207
198
// CHECK-SIL-NOT: cond_fail {{.*}}, "Index out of bounds"
208
- // CHECK-SIL: cond_br
209
199
// CHECK-SIL-LABEL: } // end sil function '$s23span_bounds_check_tests0A31_iterate_over_indices_with_trapySis4SpanVySiGF'
210
200
public func span_iterate_over_indices_with_trap( _ v: Span < Int > ) -> Int {
211
201
var sum = 0
@@ -254,12 +244,11 @@ public func span_search<T : Equatable>(_ v: Span<T>, _ elem: T) -> Int? {
254
244
return nil
255
245
}
256
246
257
- // Bounds check should be eliminated
247
+ // TODO: Bounds check should be eliminated
258
248
259
249
// CHECK-SIL-LABEL: sil @$s23span_bounds_check_tests0A11_search_splySiSgs4SpanVySiG_SitF :
260
250
// CHECK-SIL: bb3:
261
251
// CHECK-SIL: cond_fail {{.*}}, "Index out of bounds"
262
- // CHECK-SIL: cond_fail {{.*}}, "Index out of bounds"
263
252
// CHECK-SIL: cond_br
264
253
// CHECK-SIL-LABEL: } // end sil function '$s23span_bounds_check_tests0A11_search_splySiSgs4SpanVySiG_SitF'
265
254
public func span_search_spl( _ v: Span < Int > , _ elem: Int ) -> Int ? {
0 commit comments