Conversation
|
r? @fee1-dead rustbot has assigned @fee1-dead. Use |
|
While writing a codegen test, looks like there's some extra work to do - pub fn none() -> i32 {
2 + 2
}emits overflow checks in opt-level=0 but not =1. It looks like with overflow checks disabled this is constant folded to |
42ac3f0 to
94815e5
Compare
|
You may need to skip mir opts too. |
|
I've turned off MIR opts in the tests for now, but I think ideally we'd want to skip running them for |
This comment has been minimized.
This comment has been minimized.
|
Unhelpfully, LLVM doesn't seem to fully account for |
94815e5 to
7154533
Compare
|
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
There was a problem hiding this comment.
I don't think this is actually correct - some of these should run in debug mode. Not sure how best to decide which passes should be omitted
There was a problem hiding this comment.
This is indeed incorrect. There are required passes that must be run on every MIR for soundness IIRC.
@rust-lang/wg-mir-opt: Anyone willing to provide assistance to how to disable MIR optimizations while only keeping the required passes?
There was a problem hiding this comment.
Maybe check it against the opt level of the pass. If it runs on opt level 0, then don't disable it
There was a problem hiding this comment.
From a brief look, there are 3 or 4 passes that need keeping, including marking the mir phase.
The easiest way would be to compute the list of passes based on the opt level, or tweak the pass manager to compare default opt level with this flag.
This comment has been minimized.
This comment has been minimized.
7154533 to
976f3e0
Compare
This comment has been minimized.
This comment has been minimized.
976f3e0 to
64434e3
Compare
There was a problem hiding this comment.
This is indeed incorrect. There are required passes that must be run on every MIR for soundness IIRC.
@rust-lang/wg-mir-opt: Anyone willing to provide assistance to how to disable MIR optimizations while only keeping the required passes?
There was a problem hiding this comment.
From a brief look, there are 3 or 4 passes that need keeping, including marking the mir phase.
The easiest way would be to compute the list of passes based on the opt level, or tweak the pass manager to compare default opt level with this flag.
|
Pushed an approach which adds a |
|
@bors try @rust-timer queue |
This comment has been minimized.
This comment has been minimized.
Add `#[optimize(none)]` cc rust-lang#54882 This extends the `optimize` attribute to add `none`, which corresponds to the LLVM `OptimizeNone` attribute. Not sure if an MCP is required for this, happy to file one if so.
|
☀️ Try build successful - checks-actions |
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (334c324): 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)Results (primary -0.4%, secondary 3.6%)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 (secondary 2.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: 762.637s -> 762.18s (-0.06%) |
e0a17a8 to
23b10ee
Compare
Co-authored-by: Waffle Lapkin <waffle.lapkin@gmail.com>
23b10ee to
7a9661d
Compare
|
@bors r=fee1-dead,WaffleLapkin |
|
☀️ Test successful - checks-actions |
|
Finished benchmarking commit (6365178): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (primary -2.2%, secondary -5.2%)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.2%, secondary 1.7%)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: 772.322s -> 771.261s (-0.14%) |
Based on what I found in #135760 (comment), it looks like the LLVM APIs won't emit So it's expected that even with optimize(none) that the IR won't have that addition. |
…ired, r=cjgillot compiler: Don't mark `SingleUseConsts` MIR pass as "required for soundness" I don't think this MIR pass is required for soundness. The reasons are: * Something like it was not enabled by default before PR rust-lang#107404 which was the precursor to `SingleUseConsts` (see rust-lang#125910 for the switch). * By following the advice from rust-lang#128657 (comment) we can conclude it is not required for soundness since it has only ever run on MIR opt level > 0. * Its [`MirPass::can_be_overridden()`](https://github.com/rust-lang/rust/blob/0ee7d96253f92b15115c94a530db8b79cb341b15/compiler/rustc_mir_transform/src/pass_manager.rs#L98-L102) is unchanged and thus returns `true`, indicating that it is not a required MIR pass. * PR CI pass in rust-lang#151426 which stops enabling it by default in non-optimized builds. As shown in the updated test `tests/mir-opt/optimize_none.rs`, `#[optimize(none)]` functions become even less optimized, as expected and desired. Unblocks rust-lang#151426.
…ired, r=cjgillot compiler: Don't mark `SingleUseConsts` MIR pass as "required for soundness" I don't think this MIR pass is required for soundness. The reasons are: * Something like it was not enabled by default before PR rust-lang#107404 which was the precursor to `SingleUseConsts` (see rust-lang#125910 for the switch). * By following the advice from rust-lang#128657 (comment) we can conclude it is not required for soundness since it has only ever run on MIR opt level > 0. * Its [`MirPass::can_be_overridden()`](https://github.com/rust-lang/rust/blob/0ee7d96253f92b15115c94a530db8b79cb341b15/compiler/rustc_mir_transform/src/pass_manager.rs#L98-L102) is unchanged and thus returns `true`, indicating that it is not a required MIR pass. * PR CI pass in rust-lang#151426 which stops enabling it by default in non-optimized builds. As shown in the updated test `tests/mir-opt/optimize_none.rs`, `#[optimize(none)]` functions become even less optimized, as expected and desired. Unblocks rust-lang#151426.
…ired, r=cjgillot compiler: Don't mark `SingleUseConsts` MIR pass as "required for soundness" I don't think this MIR pass is required for soundness. The reasons are: * Something like it was not enabled by default before PR rust-lang#107404 which was the precursor to `SingleUseConsts` (see rust-lang#125910 for the switch). * By following the advice from rust-lang#128657 (comment) we can conclude it is not required for soundness since it has only ever run on MIR opt level > 0. * Its [`MirPass::can_be_overridden()`](https://github.com/rust-lang/rust/blob/0ee7d96253f92b15115c94a530db8b79cb341b15/compiler/rustc_mir_transform/src/pass_manager.rs#L98-L102) is unchanged and thus returns `true`, indicating that it is not a required MIR pass. * PR CI pass in rust-lang#151426 which stops enabling it by default in non-optimized builds. As shown in the updated test `tests/mir-opt/optimize_none.rs`, `#[optimize(none)]` functions become even less optimized, as expected and desired. Unblocks rust-lang#151426.
…ired, r=cjgillot compiler: Don't mark `SingleUseConsts` MIR pass as "required for soundness" I don't think this MIR pass is required for soundness. The reasons are: * Something like it was not enabled by default before PR rust-lang#107404 which was the precursor to `SingleUseConsts` (see rust-lang#125910 for the switch). * By following the advice from rust-lang#128657 (comment) we can conclude it is not required for soundness since it has only ever run on MIR opt level > 0. * Its [`MirPass::can_be_overridden()`](https://github.com/rust-lang/rust/blob/0ee7d96253f92b15115c94a530db8b79cb341b15/compiler/rustc_mir_transform/src/pass_manager.rs#L98-L102) is unchanged and thus returns `true`, indicating that it is not a required MIR pass. * PR CI pass in rust-lang#151426 which stops enabling it by default in non-optimized builds. As shown in the updated test `tests/mir-opt/optimize_none.rs`, `#[optimize(none)]` functions become even less optimized, as expected and desired. Unblocks rust-lang#151426.
Rollup merge of #152729 - Enselic:single_use_consts-not-required, r=cjgillot compiler: Don't mark `SingleUseConsts` MIR pass as "required for soundness" I don't think this MIR pass is required for soundness. The reasons are: * Something like it was not enabled by default before PR #107404 which was the precursor to `SingleUseConsts` (see #125910 for the switch). * By following the advice from #128657 (comment) we can conclude it is not required for soundness since it has only ever run on MIR opt level > 0. * Its [`MirPass::can_be_overridden()`](https://github.com/rust-lang/rust/blob/0ee7d96253f92b15115c94a530db8b79cb341b15/compiler/rustc_mir_transform/src/pass_manager.rs#L98-L102) is unchanged and thus returns `true`, indicating that it is not a required MIR pass. * PR CI pass in #151426 which stops enabling it by default in non-optimized builds. As shown in the updated test `tests/mir-opt/optimize_none.rs`, `#[optimize(none)]` functions become even less optimized, as expected and desired. Unblocks #151426.
cc #54882
This extends the
optimizeattribute to addnone, which corresponds to the LLVMOptimizeNoneattribute.Not sure if an MCP is required for this, happy to file one if so.