From 6b26640583649b6e688f7c1d82778a555bf66b79 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Mon, 12 Jul 2021 18:45:56 +0200 Subject: [PATCH] remove unnecessary deallocate_local hack --- .../rustc_mir/src/interpret/eval_context.rs | 6 +++--- compiler/rustc_mir/src/interpret/memory.rs | 17 +++++------------ 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/compiler/rustc_mir/src/interpret/eval_context.rs b/compiler/rustc_mir/src/interpret/eval_context.rs index 648a7abfdc7..8cd459265df 100644 --- a/compiler/rustc_mir/src/interpret/eval_context.rs +++ b/compiler/rustc_mir/src/interpret/eval_context.rs @@ -18,8 +18,8 @@ use rustc_target::abi::{Align, HasDataLayout, LayoutOf, Size, TargetDataLayout}; use super::{ - Immediate, MPlaceTy, Machine, MemPlace, MemPlaceMeta, Memory, Operand, Place, PlaceTy, - ScalarMaybeUninit, StackPopJump, + Immediate, MPlaceTy, Machine, MemPlace, MemPlaceMeta, Memory, MemoryKind, Operand, Place, + PlaceTy, ScalarMaybeUninit, StackPopJump, }; use crate::transform::validate::equal_up_to_regions; use crate::util::storage::AlwaysLiveLocals; @@ -900,7 +900,7 @@ fn deallocate_local(&mut self, local: LocalValue) -> InterpResult // due to the local having ZST type. let ptr = ptr.assert_ptr(); trace!("deallocating local: {:?}", self.memory.dump_alloc(ptr.alloc_id)); - self.memory.deallocate_local(ptr)?; + self.memory.deallocate(ptr, None, MemoryKind::Stack)?; }; Ok(()) } diff --git a/compiler/rustc_mir/src/interpret/memory.rs b/compiler/rustc_mir/src/interpret/memory.rs index 990dbbcd250..5f719cc1607 100644 --- a/compiler/rustc_mir/src/interpret/memory.rs +++ b/compiler/rustc_mir/src/interpret/memory.rs @@ -276,17 +276,6 @@ pub fn reallocate( Ok(new_ptr) } - /// Deallocate a local, or do nothing if that local has been made into a global. - pub fn deallocate_local(&mut self, ptr: Pointer) -> InterpResult<'tcx> { - // The allocation might be already removed by global interning. - // This can only really happen in the CTFE instance, not in miri. - if self.alloc_map.contains_key(&ptr.alloc_id) { - self.deallocate(ptr, None, MemoryKind::Stack) - } else { - Ok(()) - } - } - pub fn deallocate( &mut self, ptr: Pointer, @@ -1110,7 +1099,11 @@ pub fn copy_repeatedly( } // now fill in all the "init" data - dest_alloc.mark_compressed_init_range(&compressed, alloc_range(dest.offset, size), num_copies); + dest_alloc.mark_compressed_init_range( + &compressed, + alloc_range(dest.offset, size), + num_copies, + ); // copy the relocations to the destination dest_alloc.mark_relocation_range(relocations); -- GitLab