From a3679aacfefb685ba16ad3d3b31573c5a66d789a Mon Sep 17 00:00:00 2001 From: Wolfgang Grieskamp Date: Mon, 26 Feb 2024 12:27:39 -0800 Subject: [PATCH] Removing left-over move inference from reference analysis --- .../pipeline/reference_safety_processor.rs | 39 +------------------ 1 file changed, 1 insertion(+), 38 deletions(-) diff --git a/third_party/move/move-compiler-v2/src/pipeline/reference_safety_processor.rs b/third_party/move/move-compiler-v2/src/pipeline/reference_safety_processor.rs index fb285af5b84403..012e84ffb0f86e 100644 --- a/third_party/move/move-compiler-v2/src/pipeline/reference_safety_processor.rs +++ b/third_party/move/move-compiler-v2/src/pipeline/reference_safety_processor.rs @@ -157,8 +157,6 @@ pub struct LifetimeState { temp_to_label_map: BTreeMap, /// A map from globals to labels. Represents root states of the active graph. global_to_label_map: BTreeMap, LifetimeLabel>, - /// Contains the set of variables whose values may have been moved to somewhere else. - moved: SetDomain, } /// Represents a node of the borrow graph. @@ -307,8 +305,6 @@ impl AbstractDomain for LifetimeState { change = JoinResult::Changed; } self.check_graph_consistency(); - - change = change.combine(self.moved.join(&other.moved)); change } } @@ -1369,11 +1365,6 @@ impl<'env, 'state> LifetimeAnalysisStep<'env, 'state> { self.check_read_local(src, mode); self.check_write_local(dest); } - // Track whether the variable content is moved - if kind == AssignKind::Move { - self.state.moved.insert(src); - } - self.state.moved.remove(&dest); } /// Process a borrow local instruction. @@ -1398,7 +1389,6 @@ impl<'env, 'state> LifetimeAnalysisStep<'env, 'state> { label, BorrowEdge::new(BorrowEdgeKind::BorrowGlobal(is_mut), loc, child), ); - self.state.moved.remove(&dest); } /// Process a borrow field instruction. @@ -1419,7 +1409,6 @@ impl<'env, 'state> LifetimeAnalysisStep<'env, 'state> { label, BorrowEdge::new(BorrowEdgeKind::BorrowField(is_mut, field_id), loc, child), ); - self.state.moved.remove(&dest); } /// Process a function call. For now we implement standard Move semantics, where every @@ -1474,20 +1463,11 @@ impl<'env, 'state> LifetimeAnalysisStep<'env, 'state> { } } } - // All sources are moved into a call - self.state.moved.extend(srcs.iter().cloned()); - for dest in dests { - self.state.moved.remove(dest); - } } /// Process a FreezeRef instruction. fn freeze_ref(&mut self, code_offset: CodeOffset, dest: TempIndex, src: TempIndex) { - let label = self - .state - .label_for_temp(src) - .expect("label for reference") - .clone(); + let label = *self.state.label_for_temp(src).expect("label for reference"); let target = self.state.replace_ref(dest, code_offset, 0); self.state.add_edge(label, BorrowEdge { kind: BorrowEdgeKind::Freeze, @@ -1511,7 +1491,6 @@ impl<'env, 'state> LifetimeAnalysisStep<'env, 'state> { self.borrow_info(label, |_| true).into_iter(), ) } - self.state.moved.remove(&dest); } /// Process a return instruction. @@ -1553,7 +1532,6 @@ impl<'env, 'state> LifetimeAnalysisStep<'env, 'state> { } } } - self.state.moved.extend(srcs.iter().cloned()) } /// Process a ReadRef instruction. @@ -1561,7 +1539,6 @@ impl<'env, 'state> LifetimeAnalysisStep<'env, 'state> { debug_assert!(self.is_ref(src)); self.check_write_local(dest); self.check_read_local(src, ReadMode::Argument); - self.state.moved.remove(&dest); } /// Process a WriteRef instruction. @@ -1733,11 +1710,6 @@ impl LifetimeInfoAtCodeOffset { .filter(|t| !self.after.temp_to_label_map.contains_key(t)) .cloned() } - - /// Returns true if the value in the variable has been moved at this program point. - pub fn is_moved(&self, temp: TempIndex) -> bool { - self.after.moved.contains(&temp) - } } impl FunctionTargetProcessor for ReferenceSafetyProcessor { @@ -1912,7 +1884,6 @@ impl<'a> Display for LifetimeStateDisplay<'a> { graph, temp_to_label_map, global_to_label_map, - moved, } = &self.1; let pool = self.0.global_env().symbol_pool(); writeln!( @@ -1939,14 +1910,6 @@ impl<'a> Display for LifetimeStateDisplay<'a> { .iter() .map(|(str, label)| format!("{}={}", self.0.global_env().display(str), label)) .join(",") - )?; - writeln!( - f, - "moved: {{{}}}", - moved - .iter() - .map(|t| self.0.get_local_raw_name(*t).display(pool).to_string()) - .join(",") ) } }