@@ -35,7 +35,7 @@ use rustc_span::{Span, Symbol};
3535#[ macro_use]
3636mod pass_manager;
3737
38- use pass_manager:: { self as pm, Lint , MirLint } ;
38+ use pass_manager:: { self as pm, Lint , MirLint , WithMinOptLevel } ;
3939
4040mod abort_unwinding_calls;
4141mod add_call_guards;
@@ -438,6 +438,10 @@ fn run_post_borrowck_cleanup_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tc
438438}
439439
440440fn 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+
441445 // Lowering generator control-flow and variables has to happen before we do anything else
442446 // to them. We run some optimizations before that, because they may be harder to do on the state
443447 // machine than on MIR with async primitives.
@@ -450,7 +454,7 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
450454 & normalize_array_len:: NormalizeArrayLen , // has to run after `slice::len` lowering
451455 & unreachable_prop:: UnreachablePropagation ,
452456 & uninhabited_enum_branching:: UninhabitedEnumBranching ,
453- & simplify:: SimplifyCfg :: new ( "after-uninhabited-enum-branching" ) ,
457+ & o1 ( simplify:: SimplifyCfg :: new ( "after-uninhabited-enum-branching" ) ) ,
454458 & inline:: Inline ,
455459 & generator:: StateTransform ,
456460 ] ,
@@ -472,17 +476,21 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
472476 & multiple_return_terminators:: MultipleReturnTerminators ,
473477 & instcombine:: InstCombine ,
474478 & separate_const_switch:: SeparateConstSwitch ,
479+ //
475480 // FIXME(#70073): This pass is responsible for both optimization as well as some lints.
476481 & 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" ) ) ,
478486 & early_otherwise_branch:: EarlyOtherwiseBranch ,
479487 & simplify_comparison_integral:: SimplifyComparisonIntegral ,
480488 & simplify_try:: SimplifyArmIdentity ,
481489 & simplify_try:: SimplifyBranchSame ,
482490 & 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" ) ) ,
486494 & nrvo:: RenameReturnPlace ,
487495 & const_debuginfo:: ConstDebugInfo ,
488496 & simplify:: SimplifyLocals ,
0 commit comments