about summary refs log tree commit diff
path: root/compiler/rustc_const_eval
diff options
context:
space:
mode:
authorLeón Orell Valerian Liehr <me@fmease.dev>2025-01-29 06:03:23 +0100
committerGitHub <noreply@github.com>2025-01-29 06:03:23 +0100
commitbde47b7ae81103febb80b45f083ef2982859ad41 (patch)
tree7fe5fea617daafcaf7f4a7a0367c086a4de783f7 /compiler/rustc_const_eval
parent3cc6ea2ac6e5f903cb00d9dd126c519ab89f5e3b (diff)
parentbc135aaa9815557704978ccf9ee15aed49f2f976 (diff)
downloadrust-bde47b7ae81103febb80b45f083ef2982859ad41.tar.gz
rust-bde47b7ae81103febb80b45f083ef2982859ad41.zip
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.)
Diffstat (limited to 'compiler/rustc_const_eval')
-rw-r--r--compiler/rustc_const_eval/src/interpret/memory.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/memory.rs b/compiler/rustc_const_eval/src/interpret/memory.rs
index 2772c94d52b..d736f14f5a3 100644
--- a/compiler/rustc_const_eval/src/interpret/memory.rs
+++ b/compiler/rustc_const_eval/src/interpret/memory.rs
@@ -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