Skip to content

Commit bde47b7

Browse files
authored
Rollup merge of rust-lang#136166 - RalfJung:interpet-is-alloc-live, r=compiler-errors
interpret: is_alloc_live: check global allocs last See rust-lang#136105 (comment). (A perf run makes no sense as this is only used by Miri.)
2 parents 3cc6ea2 + bc135aa commit bde47b7

File tree

1 file changed

+4
-2
lines changed
  • compiler/rustc_const_eval/src/interpret

1 file changed

+4
-2
lines changed

compiler/rustc_const_eval/src/interpret/memory.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -830,9 +830,11 @@ impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
830830
/// [`InterpCx::get_alloc_info`] if all you need to check is whether the kind is
831831
/// [`AllocKind::Dead`] because it doesn't have to look up the type and layout of statics.
832832
pub fn is_alloc_live(&self, id: AllocId) -> bool {
833-
self.tcx.try_get_global_alloc(id).is_some()
834-
|| self.memory.alloc_map.contains_key_ref(&id)
833+
self.memory.alloc_map.contains_key_ref(&id)
835834
|| self.memory.extra_fn_ptr_map.contains_key(&id)
835+
// We check `tcx` last as that has to acquire a lock in `many-seeds` mode.
836+
// This also matches the order in `get_alloc_info`.
837+
|| self.tcx.try_get_global_alloc(id).is_some()
836838
}
837839

838840
/// Obtain the size and alignment of an allocation, even if that allocation has

0 commit comments

Comments
 (0)