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_ssa/src | |
| parent | e2163008763c326ec4003e07b8e6eef0c98f6204 (diff) | |
| download | rust-8ccf53332e2ab70fa4efed5716ddcbb61e98dac2.tar.gz rust-8ccf53332e2ab70fa4efed5716ddcbb61e98dac2.zip | |
A MIR transform that checks pointers are aligned
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/mir/block.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_ssa/src/mir/block.rs b/compiler/rustc_codegen_ssa/src/mir/block.rs index 5da0e826c56..343ecd3613f 100644 --- a/compiler/rustc_codegen_ssa/src/mir/block.rs +++ b/compiler/rustc_codegen_ssa/src/mir/block.rs @@ -600,6 +600,13 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> { // and `#[track_caller]` adds an implicit third argument. (LangItem::PanicBoundsCheck, vec![index, len, location]) } + AssertKind::MisalignedPointerDereference { ref required, ref found } => { + let required = self.codegen_operand(bx, required).immediate(); + let found = self.codegen_operand(bx, found).immediate(); + // It's `fn panic_bounds_check(index: usize, len: usize)`, + // and `#[track_caller]` adds an implicit third argument. + (LangItem::PanicMisalignedPointerDereference, vec![required, found, location]) + } _ => { let msg = bx.const_str(msg.description()); // It's `pub fn panic(expr: &str)`, with the wide reference being passed |
