|
| 1 | +// no-system-llvm |
| 2 | +// compile-flags: -O |
| 3 | +// ignore-debug (these add extra checks that make it hard to verify) |
| 4 | +#![crate_type = "lib"] |
| 5 | + |
| 6 | +// The slice iterator used to `assume` that the `start` pointer was non-null. |
| 7 | +// That ought to be unneeded, though, since the type is `NonNull`, so this test |
| 8 | +// confirms that the appropriate metadata is included to denote that. |
| 9 | + |
| 10 | +// CHECK-LABEL: @slice_iter_next( |
| 11 | +#[no_mangle] |
| 12 | +pub fn slice_iter_next<'a>(it: &mut std::slice::Iter<'a, u32>) -> Option<&'a u32> { |
| 13 | + // CHECK: %[[ENDP:.+]] = getelementptr{{.+}}ptr %it,{{.+}} 1 |
| 14 | + // CHECK: %[[END:.+]] = load ptr, ptr %[[ENDP]] |
| 15 | + // CHECK-SAME: !nonnull |
| 16 | + // CHECK-SAME: !noundef |
| 17 | + // CHECK: %[[START:.+]] = load ptr, ptr %it, |
| 18 | + // CHECK-SAME: !nonnull |
| 19 | + // CHECK-SAME: !noundef |
| 20 | + // CHECK: icmp eq ptr %[[START]], %[[END]] |
| 21 | + |
| 22 | + // CHECK: store ptr{{.+}}, ptr %it, |
| 23 | + |
| 24 | + it.next() |
| 25 | +} |
| 26 | + |
| 27 | +// CHECK-LABEL: @slice_iter_next_back( |
| 28 | +#[no_mangle] |
| 29 | +pub fn slice_iter_next_back<'a>(it: &mut std::slice::Iter<'a, u32>) -> Option<&'a u32> { |
| 30 | + // CHECK: %[[ENDP:.+]] = getelementptr{{.+}}ptr %it,{{.+}} 1 |
| 31 | + // CHECK: %[[END:.+]] = load ptr, ptr %[[ENDP]] |
| 32 | + // CHECK-SAME: !nonnull |
| 33 | + // CHECK-SAME: !noundef |
| 34 | + // CHECK: %[[START:.+]] = load ptr, ptr %it, |
| 35 | + // CHECK-SAME: !nonnull |
| 36 | + // CHECK-SAME: !noundef |
| 37 | + // CHECK: icmp eq ptr %[[START]], %[[END]] |
| 38 | + |
| 39 | + // CHECK: store ptr{{.+}}, ptr %[[ENDP]], |
| 40 | + |
| 41 | + it.next_back() |
| 42 | +} |
0 commit comments