From 8b18860677a84778478deed4408586ebaaac868b Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Thu, 10 Nov 2022 11:37:28 -0500 Subject: [PATCH] A MIR transform that checks pointers are aligned --- src/base.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/base.rs b/src/base.rs index 2107ae147e9..67ed2b33c5a 100644 --- a/src/base.rs +++ b/src/base.rs @@ -379,6 +379,18 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) { source_info.span, ); } + AssertKind::MisalignedPointerDereference { ref required, ref found } => { + let required = codegen_operand(fx, required).load_scalar(fx); + let found = codegen_operand(fx, found).load_scalar(fx); + let location = fx.get_caller_location(source_info).load_scalar(fx); + + codegen_panic_inner( + fx, + rustc_hir::LangItem::PanicBoundsCheck, + &[required, found, location], + source_info.span, + ); + } _ => { let msg_str = msg.description(); codegen_panic(fx, msg_str, source_info);