1
Fork 0

Rollup merge of #61120 - spastorino:eval-place-iterate, r=oli-obk

Make eval_place iterate instead of recurse

r? @oli-obk
This commit is contained in:
Mazdak Farrokhzad 2019-05-26 13:37:57 +02:00 committed by GitHub
commit c3e1f99a69
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -607,42 +607,42 @@ where
/// place; for reading, a more efficient alternative is `eval_place_for_read`. /// place; for reading, a more efficient alternative is `eval_place_for_read`.
pub fn eval_place( pub fn eval_place(
&mut self, &mut self,
mir_place: &mir::Place<'tcx> mir_place: &mir::Place<'tcx>,
) -> EvalResult<'tcx, PlaceTy<'tcx, M::PointerTag>> { ) -> EvalResult<'tcx, PlaceTy<'tcx, M::PointerTag>> {
use rustc::mir::Place::*;
use rustc::mir::PlaceBase; use rustc::mir::PlaceBase;
let place = match mir_place {
Base(PlaceBase::Local(mir::RETURN_PLACE)) => match self.frame().return_place { mir_place.iterate(|place_base, place_projection| {
Some(return_place) => let mut place = match place_base {
// We use our layout to verify our assumption; caller will validate PlaceBase::Local(mir::RETURN_PLACE) => match self.frame().return_place {
// their layout on return. Some(return_place) => {
PlaceTy { // We use our layout to verify our assumption; caller will validate
place: *return_place, // their layout on return.
layout: self.layout_of(self.monomorphize(self.frame().mir.return_ty())?)?, PlaceTy {
}, place: *return_place,
None => return err!(InvalidNullPointerUsage), layout: self
}, .layout_of(self.monomorphize(self.frame().mir.return_ty())?)?,
Base(PlaceBase::Local(local)) => PlaceTy { }
// This works even for dead/uninitialized locals; we check further when writing }
place: Place::Local { None => return err!(InvalidNullPointerUsage),
frame: self.cur_frame(),
local: *local,
}, },
layout: self.layout_of_local(self.frame(), *local, None)?, PlaceBase::Local(local) => PlaceTy {
}, // This works even for dead/uninitialized locals; we check further when writing
place: Place::Local {
frame: self.cur_frame(),
local: *local,
},
layout: self.layout_of_local(self.frame(), *local, None)?,
},
PlaceBase::Static(place_static) => self.eval_static_to_mplace(place_static)?.into(),
};
Projection(proj) => { for proj in place_projection {
let place = self.eval_place(&proj.base)?; place = self.place_projection(place, &proj.elem)?
self.place_projection(place, &proj.elem)?
} }
Base(PlaceBase::Static(place_static)) => { self.dump_place(place.place);
self.eval_static_to_mplace(place_static)?.into() Ok(place)
} })
};
self.dump_place(place.place);
Ok(place)
} }
/// Write a scalar to a place /// Write a scalar to a place