add range metadata to alignment loads

This commit is contained in:
Ralf Jung 2022-07-20 10:45:09 -04:00
parent 399e020b96
commit 9cbd1066d7

View File

@ -9,7 +9,7 @@
use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_span::{sym, Span};
use rustc_target::abi::call::{FnAbi, PassMode};
use rustc_target::abi::{WrappingRange, call::{FnAbi, PassMode}};
fn copy_intrinsic<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
bx: &mut Bx,
@ -110,7 +110,12 @@ pub fn codegen_intrinsic_call(
sym::vtable_align => ty::COMMON_VTABLE_ENTRIES_ALIGN,
_ => bug!(),
};
meth::VirtualIndex::from_index(idx).get_usize(bx, vtable)
let value = meth::VirtualIndex::from_index(idx).get_usize(bx, vtable);
if name == sym::vtable_align {
// Alignment is always nonzero.
bx.range_metadata(value, WrappingRange { start: 1, end: !0 });
};
value
}
sym::pref_align_of
| sym::needs_drop