From e33790d8e728bb3c89c9c6e2584e1fb5e1f5785e Mon Sep 17 00:00:00 2001 From: Chris Fallin Date: Tue, 8 Jun 2021 01:30:29 -0700 Subject: [PATCH] do not remove redundant move if we don't have local (within-basic-block) vreg tags, as this might throw off the checker --- src/ion/mod.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/ion/mod.rs b/src/ion/mod.rs index 020811c..ad2e0a4 100644 --- a/src/ion/mod.rs +++ b/src/ion/mod.rs @@ -883,6 +883,9 @@ impl RedundantMoveEliminator { log::debug!(" -> existing_dst_vreg {:?}", existing_dst_vreg); let elide = match (from_state, to_state) { + // can't elide if we don't know the implications for the + // checker. + _ if src_vreg.is_none() && dst_vreg.is_none() => false, (_, RedundantMoveState::Copy(orig_alloc, _)) if orig_alloc == from => true, (RedundantMoveState::Copy(new_alloc, _), _) if new_alloc == to => true, _ => false, @@ -930,6 +933,14 @@ impl RedundantMoveEliminator { if let Some(ref mut existing_copies) = self.reverse_allocs.get_mut(&alloc) { for to_inval in existing_copies.iter() { log::debug!(" -> clear existing copy: {:?}", to_inval); + if let Some(val) = self.allocs.get_mut(to_inval) { + match val { + RedundantMoveState::Copy(_, Some(vreg)) => { + *val = RedundantMoveState::Orig(*vreg); + } + _ => *val = RedundantMoveState::None, + } + } self.allocs.remove(to_inval); } existing_copies.clear();