diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-03-27 08:46:52 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-27 08:46:52 +0200 |
| commit | 32aa4c03d91f7bb5c22f86b8da3f1746e933e8fd (patch) | |
| tree | eb70094ae8e04d5c21d57d19f5d616042714df80 /compiler/rustc_query_system | |
| parent | 704991c959f8507b92a6440b5be0ad89e41682a3 (diff) | |
| parent | 5e49f099a9a6a4bf9776315e19b58b09fb159f87 (diff) | |
| download | rust-32aa4c03d91f7bb5c22f86b8da3f1746e933e8fd.tar.gz rust-32aa4c03d91f7bb5c22f86b8da3f1746e933e8fd.zip | |
Rollup merge of #109587 - cjgillot:no-hashmap-fingerprint, r=Nilstrieb
Use an IndexVec to debug fingerprints. Uncontroversial part of https://github.com/rust-lang/rust/pull/109050
Diffstat (limited to 'compiler/rustc_query_system')
| -rw-r--r-- | compiler/rustc_query_system/src/dep_graph/graph.rs | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/compiler/rustc_query_system/src/dep_graph/graph.rs b/compiler/rustc_query_system/src/dep_graph/graph.rs index 80618fd1abe..2ff7de8cb9e 100644 --- a/compiler/rustc_query_system/src/dep_graph/graph.rs +++ b/compiler/rustc_query_system/src/dep_graph/graph.rs @@ -1065,7 +1065,7 @@ pub(super) struct CurrentDepGraph<K: DepKind> { /// This is used to verify that fingerprints do not change between the creation of a node /// and its recomputation. #[cfg(debug_assertions)] - fingerprints: Lock<FxHashMap<DepNode<K>, Fingerprint>>, + fingerprints: Lock<IndexVec<DepNodeIndex, Option<Fingerprint>>>, /// Used to trap when a specific edge is added to the graph. /// This is used for debug purposes and is only active with `debug_assertions`. @@ -1151,7 +1151,7 @@ impl<K: DepKind> CurrentDepGraph<K> { #[cfg(debug_assertions)] forbidden_edge, #[cfg(debug_assertions)] - fingerprints: Lock::new(Default::default()), + fingerprints: Lock::new(IndexVec::from_elem_n(None, new_node_count_estimate)), total_read_count: AtomicU64::new(0), total_duplicate_read_count: AtomicU64::new(0), node_intern_event_id, @@ -1163,14 +1163,8 @@ impl<K: DepKind> CurrentDepGraph<K> { if let Some(forbidden_edge) = &self.forbidden_edge { forbidden_edge.index_to_node.lock().insert(dep_node_index, key); } - match self.fingerprints.lock().entry(key) { - Entry::Vacant(v) => { - v.insert(fingerprint); - } - Entry::Occupied(o) => { - assert_eq!(*o.get(), fingerprint, "Unstable fingerprints for {:?}", key); - } - } + let previous = *self.fingerprints.lock().get_or_insert_with(dep_node_index, || fingerprint); + assert_eq!(previous, fingerprint, "Unstable fingerprints for {:?}", key); } /// Writes the node to the current dep-graph and allocates a `DepNodeIndex` for it. |
