Skip to content

Commit

Permalink
does this help perf?
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Sep 27, 2023
1 parent d1bd83c commit 6d02d7d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
7 changes: 3 additions & 4 deletions compiler/rustc_const_eval/src/interpret/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,10 +455,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
ptr: Pointer<Option<M::Provenance>>,
align: Align,
) -> Option<Misalignment> {
if !M::enforce_alignment(self) || align.bytes() == 1 {
return None;
}

#[inline]
fn offset_misalignment(offset: u64, align: Align) -> Option<Misalignment> {
if offset % align.bytes() == 0 {
Expand Down Expand Up @@ -497,6 +493,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
ptr: Pointer<Option<M::Provenance>>,
align: Align,
) -> InterpResult<'tcx> {
if !M::enforce_alignment(self) || align.bytes() == 1 {
return Ok(());
}
self.check_misalign(self.is_ptr_misaligned(ptr, align), CheckAlignMsg::AccessedPtr)
}
}
Expand Down
6 changes: 5 additions & 1 deletion compiler/rustc_const_eval/src/interpret/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,11 @@ where
meta: MemPlaceMeta<M::Provenance>,
layout: TyAndLayout<'tcx>,
) -> MPlaceTy<'tcx, M::Provenance> {
let misaligned = self.is_ptr_misaligned(ptr, layout.align.abi);
let misaligned = if !M::enforce_alignment(self) || layout.align.abi.bytes() == 1 {
None
} else {
self.is_ptr_misaligned(ptr, layout.align.abi)
};
MPlaceTy { mplace: MemPlace { ptr, meta, misaligned }, layout }
}

Expand Down

0 comments on commit 6d02d7d

Please sign in to comment.