Remove single field struct by just using the field

This commit is contained in:
Oliver Schneider 2018-01-29 11:38:47 +01:00
parent e093ab0df4
commit c568807989
No known key found for this signature in database
GPG Key ID: A69F8D225B3AD7D9

View File

@ -52,7 +52,7 @@ struct OptimizationFinder<'b, 'a, 'tcx:'a+'b> {
mir: &'b Mir<'tcx>,
tcx: TyCtxt<'a, 'tcx, 'tcx>,
source: MirSource,
optimizations: OptimizationList<'tcx>,
places: FxHashMap<Local, Const<'tcx>>,
}
impl<'b, 'a, 'tcx:'b> OptimizationFinder<'b, 'a, 'tcx> {
@ -65,7 +65,7 @@ impl<'b, 'a, 'tcx:'b> OptimizationFinder<'b, 'a, 'tcx> {
mir,
tcx,
source,
optimizations: OptimizationList::default(),
places: FxHashMap::default(),
}
}
@ -117,7 +117,7 @@ impl<'b, 'a, 'tcx:'b> OptimizationFinder<'b, 'a, 'tcx> {
match *op {
Operand::Constant(ref c) => self.eval_constant(c),
Operand::Move(ref place) | Operand::Copy(ref place) => match *place {
Place::Local(loc) => self.optimizations.places.get(&loc).cloned(),
Place::Local(loc) => self.places.get(&loc).cloned(),
// FIXME(oli-obk): field and index projections
Place::Projection(_) => None,
_ => None,
@ -353,7 +353,7 @@ impl<'b, 'a, 'tcx> Visitor<'tcx> for OptimizationFinder<'b, 'a, 'tcx> {
if self.mir.local_kind(local) == LocalKind::Temp
&& CanConstProp::check(local, self.mir) {
trace!("storing {:?} to {:?}", value, local);
assert!(self.optimizations.places.insert(local, value).is_none());
assert!(self.places.insert(local, value).is_none());
}
}
}
@ -443,8 +443,3 @@ impl<'b, 'a, 'tcx> Visitor<'tcx> for OptimizationFinder<'b, 'a, 'tcx> {
}
}
}
#[derive(Default)]
struct OptimizationList<'tcx> {
places: FxHashMap<Local, Const<'tcx>>,
}