-
Notifications
You must be signed in to change notification settings - Fork 12.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get !nonnull
metadata on slice iterators, without assume
s
#113344
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
@@ -68,7 +68,7 @@ pub struct Iter<'a, T: 'a> { | |||
/// For non-ZSTs, the non-null pointer to the past-the-end element. | |||
/// | |||
/// For ZSTs, this is `ptr::invalid(len)`. | |||
end: *const T, | |||
end_or_len: *const T, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish this could use a union
, but it can't because that makes it able to store undef
, which we don't want.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Time for a MostCertainlyInitialized<T>
? 😄
pub fn slice_iter_is_empty(it: &std::slice::Iter<'_, u32>) -> bool { | ||
// CHECK: %[[ENDP:.+]] = getelementptr{{.+}}ptr %it,{{.+}} 1 | ||
// CHECK: %[[END:.+]] = load ptr, ptr %[[ENDP]] | ||
// CHECK-SAME: !nonnull |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Today on nightly this load does not get the !nonnull
annotation: https://play.rust-lang.org/?version=nightly&mode=release&edition=2021&gist=f0f3975ca7167a382f36e67e628f69e2
☔ The latest upstream changes (presumably #113508) made this pull request unmergeable. Please resolve the merge conflicts. |
54997bf
to
2e899a0
Compare
r? @the8472 |
Except for the comment it looks good. Probably should do a perf run, although I do expect that if there are any regressions they would be due to llvm doing more work. |
☔ The latest upstream changes (presumably #113758) made this pull request unmergeable. Please resolve the merge conflicts. |
2e899a0
to
34732e8
Compare
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
⌛ Trying commit 34732e8 with merge f1e8277ffa6108869c09034cdcea0749e0856e26... |
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (f1e8277ffa6108869c09034cdcea0749e0856e26): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @bors rollup=never Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Bootstrap: 649.387s -> 652.821s (0.53%) |
That's probably more neutral than the summary looks, since the 8% wins are in an opt-incr (though squinting at the graph I don't think they're noise?), but I think the perf results are entirely tolerable for landing this. There's unfortunately some more code in debug, since not being able to use a @bors r=the8472 |
☀️ Test successful - checks-actions |
Finished benchmarking commit (c720a9c): comparison URL. Overall result: ❌✅ regressions and improvements - ACTION NEEDEDNext Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Bootstrap: 651.863s -> 649.563s (-0.35%) |
The one regression appears to be some really bad luck in codegen, as something went very weird in LTO: Not sure how this change would affect that one so badly, but not other things. |
Huh, I never realized that kind of graphical view was available on perf.rust-lang.org. TIL. |
Interesting that it makes such a difference. I would have assumed that the vec::IntoIter does quite similar stuff. I'll check if this trick can be applied there too. |
Visiting for weekly performance triage
@rustbot label: +perf-regression-triaged |
mark vec::IntoIter pointers as `!nonnull` This applies the same NonNull optimizations to `vec::IntoIter` as rust-lang#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`
mark vec::IntoIter pointers as `!nonnull` This applies the same NonNull optimizations to `vec::IntoIter` as rust-lang#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`
mark vec::IntoIter pointers as `!nonnull` This applies the same NonNull optimizations to `vec::IntoIter` as rust-lang#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`
mark vec::IntoIter pointers as `!nonnull` This applies the same NonNull optimizations to `vec::IntoIter` as rust-lang#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`
This updates the non-ZST paths to read the end pointer through a pointer-to-
NonNull
, so that they all get!nonnull
metadata.That means that the last
assume(!ptr.is_null())
can be deleted, without impacting codegen -- the codegen tests confirm the LLVM-IR ends up exactly the same as before.