From 6c9d7fbeedd31398f363185106da292c2cdccb7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Sun, 14 Feb 2021 00:00:00 +0000 Subject: [PATCH] Add size assertions for interpreter data structures --- compiler/rustc_mir/src/interpret/operand.rs | 9 +++++++++ compiler/rustc_mir/src/interpret/place.rs | 15 +++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/compiler/rustc_mir/src/interpret/operand.rs b/compiler/rustc_mir/src/interpret/operand.rs index 88236458a21..96fe22cab19 100644 --- a/compiler/rustc_mir/src/interpret/operand.rs +++ b/compiler/rustc_mir/src/interpret/operand.rs @@ -32,6 +32,9 @@ pub enum Immediate { ScalarPair(ScalarMaybeUninit, ScalarMaybeUninit), } +#[cfg(target_arch = "x86_64")] +rustc_data_structures::static_assert_size!(Immediate, 56); + impl From> for Immediate { #[inline(always)] fn from(val: ScalarMaybeUninit) -> Self { @@ -92,6 +95,9 @@ pub struct ImmTy<'tcx, Tag = ()> { pub layout: TyAndLayout<'tcx>, } +#[cfg(target_arch = "x86_64")] +rustc_data_structures::static_assert_size!(ImmTy<'_>, 72); + impl std::fmt::Display for ImmTy<'tcx, Tag> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { /// Helper function for printing a scalar to a FmtPrinter @@ -156,6 +162,9 @@ pub struct OpTy<'tcx, Tag = ()> { pub layout: TyAndLayout<'tcx>, } +#[cfg(target_arch = "x86_64")] +rustc_data_structures::static_assert_size!(OpTy<'_, ()>, 80); + impl<'tcx, Tag> std::ops::Deref for OpTy<'tcx, Tag> { type Target = Operand; #[inline(always)] diff --git a/compiler/rustc_mir/src/interpret/place.rs b/compiler/rustc_mir/src/interpret/place.rs index efde7fe6948..b79b3d92154 100644 --- a/compiler/rustc_mir/src/interpret/place.rs +++ b/compiler/rustc_mir/src/interpret/place.rs @@ -33,6 +33,9 @@ pub enum MemPlaceMeta { Poison, } +#[cfg(target_arch = "x86_64")] +rustc_data_structures::static_assert_size!(MemPlaceMeta, 24); + impl MemPlaceMeta { pub fn unwrap_meta(self) -> Scalar { match self { @@ -71,6 +74,9 @@ pub struct MemPlace { pub meta: MemPlaceMeta, } +#[cfg(target_arch = "x86_64")] +rustc_data_structures::static_assert_size!(MemPlace, 56); + #[derive(Copy, Clone, Debug, Hash, PartialEq, Eq, HashStable)] pub enum Place { /// A place referring to a value allocated in the `Memory` system. @@ -81,12 +87,18 @@ pub enum Place { Local { frame: usize, local: mir::Local }, } +#[cfg(target_arch = "x86_64")] +rustc_data_structures::static_assert_size!(Place, 64); + #[derive(Copy, Clone, Debug)] pub struct PlaceTy<'tcx, Tag = ()> { place: Place, // Keep this private; it helps enforce invariants. pub layout: TyAndLayout<'tcx>, } +#[cfg(target_arch = "x86_64")] +rustc_data_structures::static_assert_size!(PlaceTy<'_>, 80); + impl<'tcx, Tag> std::ops::Deref for PlaceTy<'tcx, Tag> { type Target = Place; #[inline(always)] @@ -102,6 +114,9 @@ pub struct MPlaceTy<'tcx, Tag = ()> { pub layout: TyAndLayout<'tcx>, } +#[cfg(target_arch = "x86_64")] +rustc_data_structures::static_assert_size!(MPlaceTy<'_>, 72); + impl<'tcx, Tag> std::ops::Deref for MPlaceTy<'tcx, Tag> { type Target = MemPlace; #[inline(always)]