diff options
| author | Ralf Jung <post@ralfj.de> | 2020-04-18 13:56:38 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2020-04-18 13:56:38 +0200 |
| commit | 41d5a77ee8fc8dc62a8264b992dfd97dae3be59d (patch) | |
| tree | 413a835fabf6cd4746c178ec22672942a57c54cb /src | |
| parent | 8d67f576b56e8fc98a31123e5963f8d00e40611c (diff) | |
| download | rust-41d5a77ee8fc8dc62a8264b992dfd97dae3be59d.tar.gz rust-41d5a77ee8fc8dc62a8264b992dfd97dae3be59d.zip | |
Miri: mplace_access_checked: offer option to force different alignment on place
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_mir/interpret/place.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/librustc_mir/interpret/place.rs b/src/librustc_mir/interpret/place.rs index 0fd930090d5..24e6833c2b4 100644 --- a/src/librustc_mir/interpret/place.rs +++ b/src/librustc_mir/interpret/place.rs @@ -333,7 +333,7 @@ where let val = self.read_immediate(src)?; trace!("deref to {} on {:?}", val.layout.ty, *val); let place = self.ref_to_mplace(val)?; - self.mplace_access_checked(place) + self.mplace_access_checked(place, None) } /// Check if the given place is good for memory access with the given @@ -361,12 +361,14 @@ where pub fn mplace_access_checked( &self, mut place: MPlaceTy<'tcx, M::PointerTag>, + force_align: Option<Align>, ) -> InterpResult<'tcx, MPlaceTy<'tcx, M::PointerTag>> { let (size, align) = self .size_and_align_of_mplace(place)? .unwrap_or((place.layout.size, place.layout.align.abi)); assert!(place.mplace.align <= align, "dynamic alignment less strict than static one?"); - place.mplace.align = align; // maximally strict checking + // Check (stricter) dynamic alignment, unless forced otherwise. + place.mplace.align = force_align.unwrap_or(align); // When dereferencing a pointer, it must be non-NULL, aligned, and live. if let Some(ptr) = self.check_mplace_access(place, Some(size))? { place.mplace.ptr = ptr.into(); |
