-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #114205 - the8472:vec-iter-nonnull, r=scottmcm
mark vec::IntoIter pointers as `!nonnull` This applies the same NonNull optimizations to `vec::IntoIter` as #113344 did for `slice::Iter` [Godbolt](https://rust.godbolt.org/z/n1cTea718) showing the test IR on current nightly, note the absence of `!nonnull` on the loads. r? `@scottmcm`
- Loading branch information
Showing
6 changed files
with
122 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// ignore-debug: the debug assertions get in the way | ||
// compile-flags: -O | ||
#![crate_type = "lib"] | ||
#![feature(exact_size_is_empty)] | ||
|
||
use std::vec; | ||
|
||
// CHECK-LABEL: @vec_iter_len_nonnull | ||
#[no_mangle] | ||
pub fn vec_iter_len_nonnull(it: &vec::IntoIter<u8>) -> usize { | ||
// CHECK: load ptr | ||
// CHECK-SAME: !nonnull | ||
// CHECK-SAME: !noundef | ||
// CHECK: load ptr | ||
// CHECK-SAME: !nonnull | ||
// CHECK-SAME: !noundef | ||
// CHECK: sub nuw | ||
// CHECK: ret | ||
it.len() | ||
} | ||
|
||
// CHECK-LABEL: @vec_iter_is_empty_nonnull | ||
#[no_mangle] | ||
pub fn vec_iter_is_empty_nonnull(it: &vec::IntoIter<u8>) -> bool { | ||
// CHECK: load ptr | ||
// CHECK-SAME: !nonnull | ||
// CHECK-SAME: !noundef | ||
// CHECK: load ptr | ||
// CHECK-SAME: !nonnull | ||
// CHECK-SAME: !noundef | ||
// CHECK: ret | ||
it.is_empty() | ||
} | ||
|
||
// CHECK-LABEL: @vec_iter_next | ||
#[no_mangle] | ||
pub fn vec_iter_next(it: &mut vec::IntoIter<u8>) -> Option<u8> { | ||
// CHECK: load ptr | ||
// CHECK-SAME: !nonnull | ||
// CHECK-SAME: !noundef | ||
// CHECK: load ptr | ||
// CHECK-SAME: !nonnull | ||
// CHECK-SAME: !noundef | ||
// CHECK: ret | ||
it.next() | ||
} |