Skip to content

Commit 52b19f7

Browse files
committed
compiler: Don't mark SingleUseConsts MIR pass as "required for soundness"
Because: * Something like it did not exist before PR 107404 * That it is not run our mir-opt-level 0 indicates that it is not required for soundness * Its `MirPass::can_be_overridden()` is unchanged and thus returns true, indicating that it is not a required MIR pass. * No test fails in PR 151426 that stops enabling by default in non-optimized builds As can be seen from the updated test `tests/mir-opt/optimize_none.rs`, this means that `#[optimize(none)]` functions become even less optimized. As expected and as desired.
1 parent 47611e1 commit 52b19f7

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

compiler/rustc_mir_transform/src/single_use_consts.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl<'tcx> crate::MirPass<'tcx> for SingleUseConsts {
8585
}
8686

8787
fn is_required(&self) -> bool {
88-
true
88+
false
8989
}
9090
}
9191

tests/mir-opt/optimize_none.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,14 @@ pub fn add_noopt() -> i32 {
1515
#[optimize(none)]
1616
pub fn const_branch() -> i32 {
1717
// CHECK-LABEL: fn const_branch(
18-
// CHECK: switchInt(const true) -> [0: [[FALSE:bb[0-9]+]], otherwise: [[TRUE:bb[0-9]+]]];
18+
// CHECK: [[BOOL:_[0-9]+]] = const true;
19+
// CHECK: switchInt(move [[BOOL]]) -> [0: [[BB_FALSE:bb[0-9]+]], otherwise: [[BB_TRUE:bb[0-9]+]]];
1920
// CHECK-NEXT: }
20-
// CHECK: [[FALSE]]: {
21+
// CHECK: [[BB_FALSE]]: {
2122
// CHECK-NEXT: _0 = const 0
2223
// CHECK-NEXT: goto
2324
// CHECK-NEXT: }
24-
// CHECK: [[TRUE]]: {
25+
// CHECK: [[BB_TRUE]]: {
2526
// CHECK-NEXT: _0 = const 1
2627
// CHECK-NEXT: goto
2728
// CHECK-NEXT: }

0 commit comments

Comments
 (0)