From 65e52bb26c0b1aff874ee5e9de22856a4d23a780 Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Fri, 14 Jul 2023 08:02:23 -0400 Subject: [PATCH] Add #[inline] to core debug assertion helpers --- library/core/src/intrinsics.rs | 3 +++ .../mem_replace.mem_replace.PreCodegen.after.mir | 10 ++-------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/library/core/src/intrinsics.rs b/library/core/src/intrinsics.rs index deef68e4699ce..d042aaf3084d6 100644 --- a/library/core/src/intrinsics.rs +++ b/library/core/src/intrinsics.rs @@ -2524,12 +2524,14 @@ pub(crate) use assert_unsafe_precondition; /// Checks whether `ptr` is properly aligned with respect to /// `align_of::()`. +#[inline] pub(crate) fn is_aligned_and_not_null(ptr: *const T) -> bool { !ptr.is_null() && ptr.is_aligned() } /// Checks whether an allocation of `len` instances of `T` exceeds /// the maximum allowed allocation size. +#[inline] pub(crate) fn is_valid_allocation_size(len: usize) -> bool { let max_len = const { let size = crate::mem::size_of::(); @@ -2540,6 +2542,7 @@ pub(crate) fn is_valid_allocation_size(len: usize) -> bool { /// Checks whether the regions of memory starting at `src` and `dst` of size /// `count * size_of::()` do *not* overlap. +#[inline] pub(crate) fn is_nonoverlapping(src: *const T, dst: *const T, count: usize) -> bool { let src_usize = src.addr(); let dst_usize = dst.addr(); diff --git a/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir index eeb2e3a1b03f6..26919dd98dd27 100644 --- a/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/mem_replace.mem_replace.PreCodegen.after.mir @@ -10,22 +10,16 @@ fn mem_replace(_1: &mut u32, _2: u32) -> u32 { scope 2 { scope 3 { debug result => _0; - scope 7 (inlined std::ptr::write::) { + scope 6 (inlined std::ptr::write::) { debug dst => _1; debug src => _2; - scope 8 { - scope 9 (inlined std::ptr::write::runtime::) { - debug dst => _1; - } + scope 7 { } } } scope 4 (inlined std::ptr::read::) { debug src => _1; scope 5 { - scope 6 (inlined std::ptr::read::runtime::) { - debug src => _1; - } } } }