diff options
| author | bors <bors@rust-lang.org> | 2023-05-13 08:57:21 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-05-13 08:57:21 +0000 |
| commit | b22bc276f84f0dab590e533cf420013356d2d321 (patch) | |
| tree | beaa06468a15fe00f6be4ad120cd4a81f9abbee2 /tests/codegen | |
| parent | 25c545114a1bc08b7b18b1a65266aae255ff2094 (diff) | |
| parent | 74319707581d99ee6609622aa03f42136cf0c197 (diff) | |
| download | rust-b22bc276f84f0dab590e533cf420013356d2d321.tar.gz rust-b22bc276f84f0dab590e533cf420013356d2d321.zip | |
Auto merge of #2893 - RalfJung:rustup, r=RalfJung
Rustup
Diffstat (limited to 'tests/codegen')
| -rw-r--r-- | tests/codegen/slice-iter-nonnull.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/codegen/slice-iter-nonnull.rs b/tests/codegen/slice-iter-nonnull.rs index 392e4338076..997bdaf5636 100644 --- a/tests/codegen/slice-iter-nonnull.rs +++ b/tests/codegen/slice-iter-nonnull.rs @@ -40,3 +40,38 @@ pub fn slice_iter_next_back<'a>(it: &mut std::slice::Iter<'a, u32>) -> Option<&' it.next_back() } + +// The slice iterator `new` methods used to `assume` that the pointer is non-null, +// but passing slices already requires that, to the extent that LLVM actually +// removed the `call @llvm.assume` anyway. These tests just demonstrate that the +// attribute is there, and confirms adding the assume back doesn't do anything. + +// CHECK-LABEL: @slice_iter_new +// CHECK-SAME: (ptr noalias noundef nonnull {{.+}} %slice.0, {{.+}} noundef %slice.1) +#[no_mangle] +pub fn slice_iter_new(slice: &[u32]) -> std::slice::Iter<'_, u32> { + // CHECK-NOT: slice + // CHECK: %[[END:.+]] = getelementptr inbounds i32{{.+}} %slice.0{{.+}} %slice.1 + // CHECK-NOT: slice + // CHECK: insertvalue {{.+}} ptr %slice.0, 0 + // CHECK-NOT: slice + // CHECK: insertvalue {{.+}} ptr %[[END]], 1 + // CHECK-NOT: slice + // CHECK: } + slice.iter() +} + +// CHECK-LABEL: @slice_iter_mut_new +// CHECK-SAME: (ptr noalias noundef nonnull {{.+}} %slice.0, {{.+}} noundef %slice.1) +#[no_mangle] +pub fn slice_iter_mut_new(slice: &mut [u32]) -> std::slice::IterMut<'_, u32> { + // CHECK-NOT: slice + // CHECK: %[[END:.+]] = getelementptr inbounds i32{{.+}} %slice.0{{.+}} %slice.1 + // CHECK-NOT: slice + // CHECK: insertvalue {{.+}} ptr %slice.0, 0 + // CHECK-NOT: slice + // CHECK: insertvalue {{.+}} ptr %[[END]], 1 + // CHECK-NOT: slice + // CHECK: } + slice.iter_mut() +} |
