From a835555474c87def84099df412816d5edfa2b9cb Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Tue, 13 Nov 2018 10:19:12 +0100 Subject: [PATCH] Make zst accesses in allocations take the regular path. Speeding up zst accesses should be done on a higher level. --- src/librustc/mir/interpret/allocation.rs | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/src/librustc/mir/interpret/allocation.rs b/src/librustc/mir/interpret/allocation.rs index 42bcd3a90276..ba2755b29f0b 100644 --- a/src/librustc/mir/interpret/allocation.rs +++ b/src/librustc/mir/interpret/allocation.rs @@ -116,12 +116,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra> Allocation { size: Size, allow_ptr_and_undef: bool, ) -> EvalResult<'tcx> { - // Empty accesses don't need to be valid pointers, but they should still be non-NULL let align = Align::from_bytes(1).unwrap(); - if size.bytes() == 0 { - self.check_align(ptr, align)?; - return Ok(()); - } // Check bounds, align and relocations on the edges self.get_bytes_with_undef_and_ptr(cx, ptr, size, align)?; // Check undef and ptr @@ -138,12 +133,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra> Allocation { ptr: Pointer, size: Size, ) -> EvalResult<'tcx, &[u8]> { - // Empty accesses don't need to be valid pointers, but they should still be non-NULL let align = Align::from_bytes(1).unwrap(); - if size.bytes() == 0 { - self.check_align(ptr, align)?; - return Ok(&[]); - } self.get_bytes(cx, ptr, size, align) } @@ -153,12 +143,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra> Allocation { ptr: Pointer, src: &[u8], ) -> EvalResult<'tcx> { - // Empty accesses don't need to be valid pointers, but they should still be non-NULL let align = Align::from_bytes(1).unwrap(); - if src.is_empty() { - self.check_align(ptr, align)?; - return Ok(()); - } let bytes = self.get_bytes_mut( cx, ptr, Size::from_bytes(src.len() as u64), align, )?; @@ -173,12 +158,7 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra> Allocation { val: u8, count: Size ) -> EvalResult<'tcx> { - // Empty accesses don't need to be valid pointers, but they should still be non-NULL let align = Align::from_bytes(1).unwrap(); - if count.bytes() == 0 { - self.check_align(ptr, align)?; - return Ok(()); - } let bytes = self.get_bytes_mut(cx, ptr, count, align)?; for b in bytes { *b = val; @@ -329,7 +309,6 @@ impl<'tcx, Tag: Copy, Extra: AllocationExtra> Allocation { align: Align, check_defined_and_ptr: bool, ) -> EvalResult<'tcx, &[u8]> { - assert_ne!(size.bytes(), 0, "0-sized accesses should never even get a `Pointer`"); self.check_align(ptr.into(), align)?; self.check_bounds(cx, ptr, size)?;