diff options
author | Ben Kimock <kimockb@gmail.com> | 2022-11-10 11:37:28 -0500 |
---|---|---|
committer | Ben Kimock <kimockb@gmail.com> | 2023-03-23 18:23:06 -0400 |
commit | 8ccf53332e2ab70fa4efed5716ddcbb61e98dac2 (patch) | |
tree | 632b4dfa8f9fcdc21d09b8fa93312d0f6a306b00 /compiler/rustc_codegen_cranelift | |
parent | e2163008763c326ec4003e07b8e6eef0c98f6204 (diff) | |
download | rust-8ccf53332e2ab70fa4efed5716ddcbb61e98dac2.tar.gz |
A MIR transform that checks pointers are aligned
Diffstat (limited to 'compiler/rustc_codegen_cranelift')
-rw-r--r-- | compiler/rustc_codegen_cranelift/src/base.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/base.rs b/compiler/rustc_codegen_cranelift/src/base.rs index 2107ae147e9..67ed2b33c5a 100644 --- a/compiler/rustc_codegen_cranelift/src/base.rs +++ b/compiler/rustc_codegen_cranelift/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); |