Cleanup ConstProp::visit_statement()
This commit is contained in:
parent
770b9e3012
commit
4592a9eb3f
1 changed files with 9 additions and 10 deletions
|
@ -431,7 +431,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
|||
place_layout: TyLayout<'tcx>,
|
||||
source_info: SourceInfo,
|
||||
place: &Place<'tcx>,
|
||||
) -> Option<Const<'tcx>> {
|
||||
) -> Option<()> {
|
||||
let span = source_info.span;
|
||||
|
||||
let overflow_check = self.tcx.sess.overflow_checks();
|
||||
|
@ -553,7 +553,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
|
|||
self.use_ecx(source_info, |this| {
|
||||
trace!("calling eval_rvalue_into_place(rvalue = {:?}, place = {:?})", rvalue, place);
|
||||
this.ecx.eval_rvalue_into_place(rvalue, place)?;
|
||||
this.ecx.eval_place_to_op(place, Some(place_layout))
|
||||
Ok(())
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -717,16 +717,15 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
|
|||
base: PlaceBase::Local(local),
|
||||
projection: box [],
|
||||
} = *place {
|
||||
if let Some(value) = self.const_prop(rval,
|
||||
place_layout,
|
||||
statement.source_info,
|
||||
place) {
|
||||
trace!("checking whether {:?} can be stored to {:?}", value, local);
|
||||
let source = statement.source_info;
|
||||
if let Some(()) = self.const_prop(rval, place_layout, source, place) {
|
||||
if self.can_const_prop[local] {
|
||||
trace!("stored {:?} to {:?}", value, local);
|
||||
assert_eq!(self.get_const(local), Some(value));
|
||||
trace!("propagated into {:?}", local);
|
||||
|
||||
if self.should_const_prop() {
|
||||
let value =
|
||||
self.get_const(local).expect("local was dead/uninitialized");
|
||||
trace!("replacing {:?} with {:?}", rval, value);
|
||||
self.replace_with_const(
|
||||
rval,
|
||||
value,
|
||||
|
@ -734,7 +733,7 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
|
|||
);
|
||||
}
|
||||
} else {
|
||||
trace!("can't propagate {:?} to {:?}", value, local);
|
||||
trace!("can't propagate into {:?}", local);
|
||||
self.remove_const(local);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue