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 rust-lang/rust#107404 which was the precursor to `SingleUseConsts` (see rust-lang/rust#125910 for the switch).
* By following the advice from https://github.com/rust-lang/rust/pull/128657#discussion_r1705114015 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()`](0ee7d96253/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/rust#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 https://github.com/rust-lang/rust/pull/151426.
This commit is contained in:
commit
dbc2193d37
2 changed files with 5 additions and 4 deletions
|
|
@ -85,7 +85,7 @@ impl<'tcx> crate::MirPass<'tcx> for SingleUseConsts {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_required(&self) -> bool {
|
fn is_required(&self) -> bool {
|
||||||
true
|
false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,14 @@ pub fn add_noopt() -> i32 {
|
||||||
#[optimize(none)]
|
#[optimize(none)]
|
||||||
pub fn const_branch() -> i32 {
|
pub fn const_branch() -> i32 {
|
||||||
// CHECK-LABEL: fn const_branch(
|
// CHECK-LABEL: fn const_branch(
|
||||||
// CHECK: switchInt(const true) -> [0: [[FALSE:bb[0-9]+]], otherwise: [[TRUE:bb[0-9]+]]];
|
// CHECK: [[BOOL:_[0-9]+]] = const true;
|
||||||
|
// CHECK: switchInt(move [[BOOL]]) -> [0: [[BB_FALSE:bb[0-9]+]], otherwise: [[BB_TRUE:bb[0-9]+]]];
|
||||||
// CHECK-NEXT: }
|
// CHECK-NEXT: }
|
||||||
// CHECK: [[FALSE]]: {
|
// CHECK: [[BB_FALSE]]: {
|
||||||
// CHECK-NEXT: _0 = const 0
|
// CHECK-NEXT: _0 = const 0
|
||||||
// CHECK-NEXT: goto
|
// CHECK-NEXT: goto
|
||||||
// CHECK-NEXT: }
|
// CHECK-NEXT: }
|
||||||
// CHECK: [[TRUE]]: {
|
// CHECK: [[BB_TRUE]]: {
|
||||||
// CHECK-NEXT: _0 = const 1
|
// CHECK-NEXT: _0 = const 1
|
||||||
// CHECK-NEXT: goto
|
// CHECK-NEXT: goto
|
||||||
// CHECK-NEXT: }
|
// CHECK-NEXT: }
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue