Skip to content

Commit

Permalink
commented out alignment check for int-aligned addrs -- need to make t…
Browse files Browse the repository at this point in the history
…he check make sense (should be len of bytes) for real addrs
  • Loading branch information
Ellen Arteca committed Aug 6, 2022
1 parent a7b7f19 commit f7a991b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion compiler/rustc_const_eval/src/interpret/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
if let Some(align) = align {
if M::force_int_for_alignment_check(self) {
// `force_int_for_alignment_check` can only be true if `OFFSET_IS_ADDR` is true.
check_offset_align(ptr.addr().bytes(), align)?;
// TODO do a proper check here
// now, addr().bytes() will not give the size of the allocation, it'll be the address
// check_offset_align(ptr.addr().bytes(), align)?;
} else {
// Check allocation alignment and offset alignment.
if alloc_align.bytes() < align.bytes() {
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_middle/src/mir/interpret/allocation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ impl<Prov> Allocation<Prov> {
let size = Size::from_bytes(slice.len());
// TODO come up with a cleaner way to align the box based on the alignment parameter
let count128 = (slice.len() / 16) + 1;
// println!("ALIGN: {:?}, {:?}", (align.bytes())+1, count128);
let mut vec128: Vec<u128> = Vec::with_capacity(count128);
// TODO avoid excess initialization
vec128.resize(count128, 0);
Expand Down Expand Up @@ -289,6 +290,7 @@ impl Allocation {
) -> Result<Allocation<Prov, Extra>, Err> {
// Compute new pointer provenance, which also adjusts the bytes.
// Realign the pointer
// println!("adjusting: {:?}, {:?}", self.align, self.bytes.len());
let count128 = (self.bytes.len() / 16) + 1;
let mut vec128: Vec<u128> = Vec::with_capacity(count128);
vec128.resize(count128, 0);
Expand Down

0 comments on commit f7a991b

Please sign in to comment.