Skip to content

Commit 32aa4c0

Browse files
authored
Rollup merge of #109587 - cjgillot:no-hashmap-fingerprint, r=Nilstrieb
Use an IndexVec to debug fingerprints. Uncontroversial part of #109050
2 parents 704991c + 5e49f09 commit 32aa4c0

File tree

1 file changed

+4
-10
lines changed
  • compiler/rustc_query_system/src/dep_graph

1 file changed

+4
-10
lines changed

Diff for: compiler/rustc_query_system/src/dep_graph/graph.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -1065,7 +1065,7 @@ pub(super) struct CurrentDepGraph<K: DepKind> {
10651065
/// This is used to verify that fingerprints do not change between the creation of a node
10661066
/// and its recomputation.
10671067
#[cfg(debug_assertions)]
1068-
fingerprints: Lock<FxHashMap<DepNode<K>, Fingerprint>>,
1068+
fingerprints: Lock<IndexVec<DepNodeIndex, Option<Fingerprint>>>,
10691069

10701070
/// Used to trap when a specific edge is added to the graph.
10711071
/// This is used for debug purposes and is only active with `debug_assertions`.
@@ -1151,7 +1151,7 @@ impl<K: DepKind> CurrentDepGraph<K> {
11511151
#[cfg(debug_assertions)]
11521152
forbidden_edge,
11531153
#[cfg(debug_assertions)]
1154-
fingerprints: Lock::new(Default::default()),
1154+
fingerprints: Lock::new(IndexVec::from_elem_n(None, new_node_count_estimate)),
11551155
total_read_count: AtomicU64::new(0),
11561156
total_duplicate_read_count: AtomicU64::new(0),
11571157
node_intern_event_id,
@@ -1163,14 +1163,8 @@ impl<K: DepKind> CurrentDepGraph<K> {
11631163
if let Some(forbidden_edge) = &self.forbidden_edge {
11641164
forbidden_edge.index_to_node.lock().insert(dep_node_index, key);
11651165
}
1166-
match self.fingerprints.lock().entry(key) {
1167-
Entry::Vacant(v) => {
1168-
v.insert(fingerprint);
1169-
}
1170-
Entry::Occupied(o) => {
1171-
assert_eq!(*o.get(), fingerprint, "Unstable fingerprints for {:?}", key);
1172-
}
1173-
}
1166+
let previous = *self.fingerprints.lock().get_or_insert_with(dep_node_index, || fingerprint);
1167+
assert_eq!(previous, fingerprint, "Unstable fingerprints for {:?}", key);
11741168
}
11751169

11761170
/// Writes the node to the current dep-graph and allocates a `DepNodeIndex` for it.

0 commit comments

Comments
 (0)