Toggle assert_unsafe_precondition in codegen instead of expansion#120594
Toggle assert_unsafe_precondition in codegen instead of expansion#120594bors merged 10 commits intorust-lang:masterfrom
Conversation
This comment has been minimized.
This comment has been minimized.
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Toggle assert_unsafe_precondition in codegen instead of expansion r? `@ghost` rust-lang#120539 (comment)
|
💥 Test timed out |
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
|
@bors retry |
Toggle assert_unsafe_precondition in codegen instead of expansion r? `@ghost` rust-lang#120539 (comment)
|
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (4ec6b4e): 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: 662.752s -> 669.21s (0.97%) |
|
The few improvements are probably because the precondition checks are always kept in MIR, so we do less MIR inlining generally, and in some cases that happens to help. Now I'm going to try to find the precondition checks that I think are least profitable and make those get toggled early. |
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Toggle assert_unsafe_precondition in codegen instead of expansion r? `@ghost` rust-lang#120539 (comment)
| bb1: { | ||
| + StorageLive(_4); | ||
| + _4 = cfg!(debug_assertions); | ||
| + assume(_4); |
There was a problem hiding this comment.
So it's expected that it doesn't directly convert to unreachable here, right?
There was a problem hiding this comment.
I didn't notice the associated comments. This is for the standard library. :)
The goal of this PR is to make some of the unsafe precondition checks in the standard library available in debug builds. Some UI tests are included to verify that it does that.
The diff is large, but most of it is blessing mir-opt tests and I've also split up this PR so it can be reviewed commit-by-commit.
This PR:
debug_assertionswhich is lowered to a new MIR NullOp, and only to a constant after monomorphizationassume_unsafe_preconditionto check the new intrinsic, and be monomorphic.assumeintrinsic in unoptimized builds, because that was silly before but with these checks it's very sillyptr::read/ptr::writeandNonNull::new_unchecked. I've simply added#[cfg(debug_assertions)]to the checks forptr::read/ptr::writebecause I was unable to come up with any (good) ideas for decreasing their impact. But forNonNull::new_uncheckedI found that the majority of callers can use a different function, often a safe one.Yes, this PR slows down the compile time of some programs. But in our benchmark suite it's never more than 1% icount, and the average icount change in debug-full programs is 0.22%. I think that is acceptable for such an improvement in developer experience.
#120539 (comment)