From 06407dd337a501931076c3fa68d6503bd72532c6 Mon Sep 17 00:00:00 2001 From: Trevor Elliott Date: Wed, 20 Jul 2022 17:01:33 -0700 Subject: [PATCH] Add a test to prevent x64 Inst size slipping further (#4489) * Add a test to prevent x64 Inst size slipping further * Enable the test for 64-bit pointers only --- cranelift/codegen/src/isa/x64/inst/mod.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/cranelift/codegen/src/isa/x64/inst/mod.rs b/cranelift/codegen/src/isa/x64/inst/mod.rs index a9d0a79146..f888bb9af3 100644 --- a/cranelift/codegen/src/isa/x64/inst/mod.rs +++ b/cranelift/codegen/src/isa/x64/inst/mod.rs @@ -43,6 +43,14 @@ pub struct CallInfo { pub opcode: Opcode, } +#[test] +#[cfg(target_pointer_width = "64")] +fn inst_size_test() { + // This test will help with unintentionally growing the size + // of the Inst enum. + assert_eq!(72, std::mem::size_of::()); +} + pub(crate) fn low32_will_sign_extend_to_64(x: u64) -> bool { let xs = x as i64; xs == ((xs << 32) >> 32)