Skip to content

Commit

Permalink
Auto merge of #117956 - saethlin:provenance-gc-access, r=RalfJung
Browse files Browse the repository at this point in the history
Let Miri see the AllocId for all TyCtxt allocations

Per rust-lang/miri#3103 (comment)

r? `@RalfJung`
  • Loading branch information
bors committed Nov 16, 2023
2 parents 1be1e84 + d7cecd3 commit 0ea7ddc
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions compiler/rustc_middle/src/mir/interpret/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,13 @@ impl<'tcx> TyCtxt<'tcx> {
self.alloc_map.lock().reserve()
}

/// Miri's provenance GC needs to see all live allocations. The interpreter manages most
/// allocations but some are managed by [`TyCtxt`] and without this method the interpreter
/// doesn't know their [`AllocId`]s are in use.
pub fn iter_allocs<F: FnMut(AllocId)>(self, func: F) {
self.alloc_map.lock().alloc_map.keys().copied().for_each(func)
}

/// Reserves a new ID *if* this allocation has not been dedup-reserved before.
/// Should only be used for "symbolic" allocations (function pointers, vtables, statics), we
/// don't want to dedup IDs for "real" memory!
Expand Down

0 comments on commit 0ea7ddc

Please sign in to comment.