@@ -35,7 +35,7 @@ use rustc_span::{Span, Symbol};
35
35
#[ macro_use]
36
36
mod pass_manager;
37
37
38
- use pass_manager:: { self as pm, Lint , MirLint } ;
38
+ use pass_manager:: { self as pm, Lint , MirLint , WithMinOptLevel } ;
39
39
40
40
mod abort_unwinding_calls;
41
41
mod add_call_guards;
@@ -438,6 +438,10 @@ fn run_post_borrowck_cleanup_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tc
438
438
}
439
439
440
440
fn run_optimization_passes < ' tcx > ( tcx : TyCtxt < ' tcx > , body : & mut Body < ' tcx > ) {
441
+ fn o1 < T > ( x : T ) -> WithMinOptLevel < T > {
442
+ WithMinOptLevel ( 1 , x)
443
+ }
444
+
441
445
// Lowering generator control-flow and variables has to happen before we do anything else
442
446
// to them. We run some optimizations before that, because they may be harder to do on the state
443
447
// machine than on MIR with async primitives.
@@ -450,7 +454,7 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
450
454
& normalize_array_len:: NormalizeArrayLen , // has to run after `slice::len` lowering
451
455
& unreachable_prop:: UnreachablePropagation ,
452
456
& uninhabited_enum_branching:: UninhabitedEnumBranching ,
453
- & simplify:: SimplifyCfg :: new ( "after-uninhabited-enum-branching" ) ,
457
+ & o1 ( simplify:: SimplifyCfg :: new ( "after-uninhabited-enum-branching" ) ) ,
454
458
& inline:: Inline ,
455
459
& generator:: StateTransform ,
456
460
] ,
@@ -472,17 +476,21 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
472
476
& multiple_return_terminators:: MultipleReturnTerminators ,
473
477
& instcombine:: InstCombine ,
474
478
& separate_const_switch:: SeparateConstSwitch ,
479
+ //
475
480
// FIXME(#70073): This pass is responsible for both optimization as well as some lints.
476
481
& const_prop:: ConstProp ,
477
- & simplify_branches:: SimplifyBranches :: new ( "after-const-prop" ) ,
482
+ //
483
+ // FIXME: The old pass manager ran this only at mir-opt-level >= 1, but
484
+ // const-prop runs unconditionally. Should this run unconditionally as well?
485
+ & o1 ( simplify_branches:: SimplifyConstCondition :: new ( "after-const-prop" ) ) ,
478
486
& early_otherwise_branch:: EarlyOtherwiseBranch ,
479
487
& simplify_comparison_integral:: SimplifyComparisonIntegral ,
480
488
& simplify_try:: SimplifyArmIdentity ,
481
489
& simplify_try:: SimplifyBranchSame ,
482
490
& dest_prop:: DestinationPropagation ,
483
- & simplify_branches:: SimplifyBranches :: new ( "final" ) ,
484
- & remove_noop_landing_pads:: RemoveNoopLandingPads ,
485
- & simplify:: SimplifyCfg :: new ( "final" ) ,
491
+ & o1 ( simplify_branches:: SimplifyConstCondition :: new ( "final" ) ) ,
492
+ & o1 ( remove_noop_landing_pads:: RemoveNoopLandingPads ) ,
493
+ & o1 ( simplify:: SimplifyCfg :: new ( "final" ) ) ,
486
494
& nrvo:: RenameReturnPlace ,
487
495
& const_debuginfo:: ConstDebugInfo ,
488
496
& simplify:: SimplifyLocals ,
0 commit comments