- // watch out for locals that do not have an
- // alloca; they are handled somewhat differently
- if let mir::Place::Base(mir::PlaceBase::Local(index)) = *place {
- match self.locals[index] {
- LocalRef::Operand(Some(o)) => {
- return Some(o);
- }
- LocalRef::Operand(None) => {
- bug!("use of {:?} before def", place);
- }
- LocalRef::Place(..) | LocalRef::UnsizedPlace(..) => {
- // use path below
- }
- }
- }
+ place.iterate(|place_base, place_projection| {
+ if let mir::PlaceBase::Local(index) = place_base {
+ match self.locals[*index] {
+ LocalRef::Operand(Some(mut o)) => {
+ // Moves out of scalar and scalar pair fields are trivial.
+ for proj in place_projection {
+ match proj.elem {
+ mir::ProjectionElem::Field(ref f, _) => {
+ o = o.extract_field(bx, f.index());
+ }
+ mir::ProjectionElem::Index(_) |
+ mir::ProjectionElem::ConstantIndex { .. } => {
+ // ZSTs don't require any actual memory access.
+ // FIXME(eddyb) deduplicate this with the identical
+ // checks in `codegen_consume` and `extract_field`.
+ let elem = o.layout.field(bx.cx(), 0);
+ if elem.is_zst() {
+ o = OperandRef::new_zst(bx, elem);
+ } else {
+ return None;
+ }
+ }
+ _ => return None,
+ }
+ }