Skip to content

Commit

Permalink
A MIR transform that checks pointers are aligned
Browse files Browse the repository at this point in the history
  • Loading branch information
saethlin committed Mar 23, 2023
1 parent 7ac6cc9 commit 8b18860
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8b18860

Please sign in to comment.