Move SimplifyLocals before ConstProp.
This commit is contained in:
parent
22e9e52c84
commit
028b4745f4
43 changed files with 348 additions and 436 deletions
|
@ -71,7 +71,7 @@ pub fn eliminate<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>, borrowed: &BitS
|
|||
bbs[block].statements[statement_index].make_nop();
|
||||
}
|
||||
|
||||
crate::simplify::SimplifyLocals.run_pass(tcx, body)
|
||||
crate::simplify::simplify_locals(body, tcx)
|
||||
}
|
||||
|
||||
pub struct DeadStoreElimination;
|
||||
|
|
|
@ -560,6 +560,7 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
|||
&multiple_return_terminators::MultipleReturnTerminators,
|
||||
&instcombine::InstCombine,
|
||||
&separate_const_switch::SeparateConstSwitch,
|
||||
&simplify::SimplifyLocals::new("before-const-prop"),
|
||||
//
|
||||
// FIXME(#70073): This pass is responsible for both optimization as well as some lints.
|
||||
&const_prop::ConstProp,
|
||||
|
@ -578,7 +579,7 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
|||
&o1(remove_noop_landing_pads::RemoveNoopLandingPads),
|
||||
&o1(simplify::SimplifyCfg::new("final")),
|
||||
&nrvo::RenameReturnPlace,
|
||||
&simplify::SimplifyLocals,
|
||||
&simplify::SimplifyLocals::new("final"),
|
||||
&multiple_return_terminators::MultipleReturnTerminators,
|
||||
&deduplicate_blocks::DeduplicateBlocks,
|
||||
// Some cleanup necessary at least for LLVM and potentially other codegen backends.
|
||||
|
|
|
@ -379,9 +379,21 @@ fn save_unreachable_coverage(
|
|||
));
|
||||
}
|
||||
|
||||
pub struct SimplifyLocals;
|
||||
pub struct SimplifyLocals {
|
||||
label: String,
|
||||
}
|
||||
|
||||
impl SimplifyLocals {
|
||||
pub fn new(label: &str) -> SimplifyLocals {
|
||||
SimplifyLocals { label: format!("SimplifyLocals-{}", label) }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> MirPass<'tcx> for SimplifyLocals {
|
||||
fn name(&self) -> &str {
|
||||
&self.label
|
||||
}
|
||||
|
||||
fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
|
||||
sess.mir_opt_level() > 0
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue