-
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
Don't emit expect
/assume
in opt-level=0
#121614
Conversation
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
expect
/assume
in opt-level=0expect
/assume
in opt-level=0
Don't emit `expect`/`assume` in opt-level=0 r? `@ghost`
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (bd65400): comparison URL. Overall result: no relevant changes - no 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. @bors rollup=never Instruction countThis benchmark run did not return any relevant results for this metric. 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.
CyclesThis benchmark run did not return any relevant results for this metric. 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.083s -> 651.832s (0.12%) |
Seems no perf impact, but is this still useful for the sake of emitting less unused IR? |
The only places we generate We only generate I'm not saying whether or not this is worth doing, just that I think the above is why this has no perf impact. Previously when my niche checks prototype was based on generating new assert terminators in MIR I found that there was a perf benefit to not emitting |
Sounds reasonable but I'm not competent. @saethlin wanna take over the review? |
Sure. |
Ouch, I just found this PR while reviewing my list of PRs and issues. We should have a bit more consistency on what we do here. For example, if we're sinking the rust/compiler/rustc_codegen_ssa/src/mir/statement.rs Lines 70 to 75 in 4e431fa
And should either delete the check here, or have evidence that sinking the check into all this code has measurable compile-time overhead (because we call all these other bx methods then don't do anything with the final bool):rust/compiler/rustc_codegen_ssa/src/mir/rvalue.rs Lines 326 to 333 in 4e431fa
Additionally, those sites check for |
@clubby789 Any updates on this? Thanks! |
45a6064
to
25264cf
Compare
Deleted the first check and used OptLevel::No (presumably, there's a chance LLVM could do something in OptLevel::Yes). There are some tests already at least for the |
This comment has been minimized.
This comment has been minimized.
25264cf
to
766253c
Compare
@@ -332,7 +332,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { | |||
scalar: abi::Scalar, | |||
backend_ty: Bx::Type, | |||
) { | |||
if matches!(self.cx.sess().opts.optimize, OptLevel::No | OptLevel::Less) |
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.
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.
Nope; leaving them on for -O1
sounds fine by me.
(I assume we don't actually have any data for it either way.)
I think IMHO, most of them are wrong, too. Anything that leads to a panic doesn't need an expect, because
|
☔ The latest upstream changes (presumably #128250) made this pull request unmergeable. Please resolve the merge conflicts. |
@clubby789 |
766253c
to
5b96ae7
Compare
Sorry - rebased and fixed up the test |
Don't emit `expect`/`assume` in opt-level=0 LLVM does not make use of expect/assume calls in `opt-level=0`, so we can simplify IR by not emitting them in this case.
Don't emit `expect`/`assume` in opt-level=0 LLVM does not make use of expect/assume calls in `opt-level=0`, so we can simplify IR by not emitting them in this case.
The job Click to see the possible cause of the failure (guessed by this bot)
|
💔 Test failed - checks-actions |
☀️ Test successful - checks-actions |
Finished benchmarking commit (54fdef7): comparison URL. Overall result: ❌ regressions - no action needed@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)Results (secondary 0.5%)This 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.
CyclesResults (primary -1.0%)This 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 sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 757.186s -> 755.979s (-0.16%) |
LLVM does not make use of expect/assume calls in
opt-level=0
, so we can simplify IR by not emitting them in this case.