Visit bodies in RPO for const-prop.
This commit is contained in:
parent
cc4d1e581e
commit
48786886fb
1 changed files with 8 additions and 7 deletions
|
@ -103,7 +103,14 @@ impl<'tcx> MirPass<'tcx> for ConstProp {
|
||||||
// That would require a uniform one-def no-mutation analysis
|
// That would require a uniform one-def no-mutation analysis
|
||||||
// and RPO (or recursing when needing the value of a local).
|
// and RPO (or recursing when needing the value of a local).
|
||||||
let mut optimization_finder = ConstPropagator::new(body, dummy_body, tcx);
|
let mut optimization_finder = ConstPropagator::new(body, dummy_body, tcx);
|
||||||
optimization_finder.visit_body(body);
|
|
||||||
|
// Traverse the body in reverse post-order, to ensure that `FullConstProp` locals are
|
||||||
|
// assigned before being read.
|
||||||
|
let postorder = body.basic_blocks.postorder().to_vec();
|
||||||
|
for bb in postorder.into_iter().rev() {
|
||||||
|
let data = &mut body.basic_blocks.as_mut_preserves_cfg()[bb];
|
||||||
|
optimization_finder.visit_basic_block_data(bb, data);
|
||||||
|
}
|
||||||
|
|
||||||
trace!("ConstProp done for {:?}", def_id);
|
trace!("ConstProp done for {:?}", def_id);
|
||||||
}
|
}
|
||||||
|
@ -790,12 +797,6 @@ impl<'tcx> MutVisitor<'tcx> for ConstPropagator<'_, 'tcx> {
|
||||||
self.tcx
|
self.tcx
|
||||||
}
|
}
|
||||||
|
|
||||||
fn visit_body(&mut self, body: &mut Body<'tcx>) {
|
|
||||||
for (bb, data) in body.basic_blocks.as_mut_preserves_cfg().iter_enumerated_mut() {
|
|
||||||
self.visit_basic_block_data(bb, data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn visit_operand(&mut self, operand: &mut Operand<'tcx>, location: Location) {
|
fn visit_operand(&mut self, operand: &mut Operand<'tcx>, location: Location) {
|
||||||
self.super_operand(operand, location);
|
self.super_operand(operand, location);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue