Skip to content

Commit 6d02d7d

Browse files
committed
does this help perf?
1 parent d1bd83c commit 6d02d7d

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

compiler/rustc_const_eval/src/interpret/memory.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -455,10 +455,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
455455
ptr: Pointer<Option<M::Provenance>>,
456456
align: Align,
457457
) -> Option<Misalignment> {
458-
if !M::enforce_alignment(self) || align.bytes() == 1 {
459-
return None;
460-
}
461-
462458
#[inline]
463459
fn offset_misalignment(offset: u64, align: Align) -> Option<Misalignment> {
464460
if offset % align.bytes() == 0 {
@@ -497,6 +493,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
497493
ptr: Pointer<Option<M::Provenance>>,
498494
align: Align,
499495
) -> InterpResult<'tcx> {
496+
if !M::enforce_alignment(self) || align.bytes() == 1 {
497+
return Ok(());
498+
}
500499
self.check_misalign(self.is_ptr_misaligned(ptr, align), CheckAlignMsg::AccessedPtr)
501500
}
502501
}

compiler/rustc_const_eval/src/interpret/place.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,11 @@ where
381381
meta: MemPlaceMeta<M::Provenance>,
382382
layout: TyAndLayout<'tcx>,
383383
) -> MPlaceTy<'tcx, M::Provenance> {
384-
let misaligned = self.is_ptr_misaligned(ptr, layout.align.abi);
384+
let misaligned = if !M::enforce_alignment(self) || layout.align.abi.bytes() == 1 {
385+
None
386+
} else {
387+
self.is_ptr_misaligned(ptr, layout.align.abi)
388+
};
385389
MPlaceTy { mplace: MemPlace { ptr, meta, misaligned }, layout }
386390
}
387391

0 commit comments

Comments
 (0)