Skip to content

Commit 16e869a

Browse files
committed
interpret: pass Size and Align to before_memory_deallocation
1 parent 79d2461 commit 16e869a

File tree

7 files changed

+18
-15
lines changed

7 files changed

+18
-15
lines changed

compiler/rustc_const_eval/src/interpret/machine.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,8 @@ pub trait Machine<'mir, 'tcx: 'mir>: Sized {
433433
_machine: &mut Self,
434434
_alloc_extra: &mut Self::AllocExtra,
435435
_prov: (AllocId, Self::ProvenanceExtra),
436-
_range: AllocRange,
436+
_size: Size,
437+
_align: Align,
437438
) -> InterpResult<'tcx> {
438439
Ok(())
439440
}

compiler/rustc_const_eval/src/interpret/memory.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,8 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
345345
&mut self.machine,
346346
&mut alloc.extra,
347347
(alloc_id, prov),
348-
alloc_range(Size::ZERO, size),
348+
size,
349+
alloc.align,
349350
)?;
350351

351352
// Don't forget to remember size and align of this now-dead allocation

src/tools/miri/src/borrow_tracker/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -472,14 +472,14 @@ impl AllocState {
472472
&mut self,
473473
alloc_id: AllocId,
474474
prov_extra: ProvenanceExtra,
475-
range: AllocRange,
475+
size: Size,
476476
machine: &MiriMachine<'_, 'tcx>,
477477
) -> InterpResult<'tcx> {
478478
match self {
479479
AllocState::StackedBorrows(sb) =>
480-
sb.get_mut().before_memory_deallocation(alloc_id, prov_extra, range, machine),
480+
sb.get_mut().before_memory_deallocation(alloc_id, prov_extra, size, machine),
481481
AllocState::TreeBorrows(tb) =>
482-
tb.get_mut().before_memory_deallocation(alloc_id, prov_extra, range, machine),
482+
tb.get_mut().before_memory_deallocation(alloc_id, prov_extra, size, machine),
483483
}
484484
}
485485

src/tools/miri/src/borrow_tracker/stacked_borrows/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -574,13 +574,13 @@ impl Stacks {
574574
&mut self,
575575
alloc_id: AllocId,
576576
tag: ProvenanceExtra,
577-
range: AllocRange,
577+
size: Size,
578578
machine: &MiriMachine<'_, 'tcx>,
579579
) -> InterpResult<'tcx> {
580-
trace!("deallocation with tag {:?}: {:?}, size {}", tag, alloc_id, range.size.bytes());
580+
trace!("deallocation with tag {:?}: {:?}, size {}", tag, alloc_id, size.bytes());
581581
let dcx = DiagnosticCxBuilder::dealloc(machine, tag);
582582
let state = machine.borrow_tracker.as_ref().unwrap().borrow();
583-
self.for_each(range, dcx, |stack, dcx, exposed_tags| {
583+
self.for_each(alloc_range(Size::ZERO, size), dcx, |stack, dcx, exposed_tags| {
584584
stack.dealloc(tag, &state, dcx, exposed_tags)
585585
})?;
586586
Ok(())

src/tools/miri/src/borrow_tracker/tree_borrows/mod.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ impl<'tcx> Tree {
8080
&mut self,
8181
alloc_id: AllocId,
8282
prov: ProvenanceExtra,
83-
range: AllocRange,
83+
size: Size,
8484
machine: &MiriMachine<'_, 'tcx>,
8585
) -> InterpResult<'tcx> {
8686
// TODO: for now we bail out on wildcard pointers. Eventually we should
@@ -91,7 +91,7 @@ impl<'tcx> Tree {
9191
};
9292
let global = machine.borrow_tracker.as_ref().unwrap();
9393
let span = machine.current_span();
94-
self.dealloc(tag, range, global, alloc_id, span)
94+
self.dealloc(tag, alloc_range(Size::ZERO, size), global, alloc_id, span)
9595
}
9696

9797
pub fn expose_tag(&mut self, _tag: BorTag) {

src/tools/miri/src/concurrency/data_race.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1071,10 +1071,10 @@ impl VClockAlloc {
10711071
pub fn deallocate<'tcx>(
10721072
&mut self,
10731073
alloc_id: AllocId,
1074-
range: AllocRange,
1074+
size: Size,
10751075
machine: &mut MiriMachine<'_, '_>,
10761076
) -> InterpResult<'tcx> {
1077-
self.unique_access(alloc_id, range, NaWriteType::Deallocate, machine)
1077+
self.unique_access(alloc_id, alloc_range(Size::ZERO, size), NaWriteType::Deallocate, machine)
10781078
}
10791079
}
10801080

src/tools/miri/src/machine.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -1288,16 +1288,17 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for MiriMachine<'mir, 'tcx> {
12881288
machine: &mut Self,
12891289
alloc_extra: &mut AllocExtra<'tcx>,
12901290
(alloc_id, prove_extra): (AllocId, Self::ProvenanceExtra),
1291-
range: AllocRange,
1291+
size: Size,
1292+
_align: Align,
12921293
) -> InterpResult<'tcx> {
12931294
if machine.tracked_alloc_ids.contains(&alloc_id) {
12941295
machine.emit_diagnostic(NonHaltingDiagnostic::FreedAlloc(alloc_id));
12951296
}
12961297
if let Some(data_race) = &mut alloc_extra.data_race {
1297-
data_race.deallocate(alloc_id, range, machine)?;
1298+
data_race.deallocate(alloc_id, size, machine)?;
12981299
}
12991300
if let Some(borrow_tracker) = &mut alloc_extra.borrow_tracker {
1300-
borrow_tracker.before_memory_deallocation(alloc_id, prove_extra, range, machine)?;
1301+
borrow_tracker.before_memory_deallocation(alloc_id, prove_extra, size, machine)?;
13011302
}
13021303
if let Some((_, deallocated_at)) = machine.allocation_spans.borrow_mut().get_mut(&alloc_id)
13031304
{

0 commit comments

Comments
 (0)