Rollup merge of #136166 - RalfJung:interpet-is-alloc-live, r=compiler-errors

interpret: is_alloc_live: check global allocs last

See https://github.com/rust-lang/rust/pull/136105#discussion_r1930609553.

(A perf run makes no sense as this is only used by Miri.)
This commit is contained in:
León Orell Valerian Liehr 2025-01-29 06:03:23 +01:00 committed by GitHub
commit bde47b7ae8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -830,9 +830,11 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
/// [`InterpCx::get_alloc_info`] if all you need to check is whether the kind is
/// [`AllocKind::Dead`] because it doesn't have to look up the type and layout of statics.
pub fn is_alloc_live(&self, id: AllocId) -> bool {
self.tcx.try_get_global_alloc(id).is_some()
|| self.memory.alloc_map.contains_key_ref(&id)
self.memory.alloc_map.contains_key_ref(&id)
|| self.memory.extra_fn_ptr_map.contains_key(&id)
// We check `tcx` last as that has to acquire a lock in `many-seeds` mode.
// This also matches the order in `get_alloc_info`.
|| self.tcx.try_get_global_alloc(id).is_some()
}
/// Obtain the size and alignment of an allocation, even if that allocation has