Skip to content

Commit e70cafe

Browse files
committed
Outline some cold code and turn on hash collision detection with debug_assertions
1 parent 5a21f89 commit e70cafe

File tree

1 file changed

+21
-16
lines changed
  • compiler/rustc_query_system/src/dep_graph

1 file changed

+21
-16
lines changed

compiler/rustc_query_system/src/dep_graph/graph.rs

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use std::sync::atomic::{AtomicU32, Ordering};
88

99
use rustc_data_structures::fingerprint::{Fingerprint, PackedFingerprint};
1010
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
11+
use rustc_data_structures::outline;
1112
use rustc_data_structures::profiling::QueryInvocationId;
1213
use rustc_data_structures::sharded::{self, Sharded};
1314
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
@@ -675,8 +676,10 @@ impl<D: Deps> DepGraphData<D> {
675676
} else if let Some(nodes_newly_allocated_in_current_session) =
676677
&self.current.nodes_newly_allocated_in_current_session
677678
{
678-
let seen = nodes_newly_allocated_in_current_session.lock().contains(dep_node);
679-
assert!(!seen, "{}", msg());
679+
outline(|| {
680+
let seen = nodes_newly_allocated_in_current_session.lock().contains(dep_node);
681+
assert!(!seen, "{}", msg());
682+
});
680683
}
681684
}
682685

@@ -1133,7 +1136,8 @@ pub(super) struct CurrentDepGraph<D: Deps> {
11331136
forbidden_edge: Option<EdgeFilter>,
11341137

11351138
/// Used to verify the absence of hash collisions among DepNodes.
1136-
/// This field is only `Some` if the `-Z incremental_verify_ich` option is present.
1139+
/// This field is only `Some` if the `-Z incremental_verify_ich` option is present
1140+
/// or if `debug_assertions` are enabled.
11371141
///
11381142
/// The map contains all DepNodes that have been allocated in the current session so far and
11391143
/// for which there is no equivalent in the previous session.
@@ -1186,6 +1190,9 @@ impl<D: Deps> CurrentDepGraph<D> {
11861190

11871191
let new_node_count_estimate = 102 * prev_graph_node_count / 100 + 200;
11881192

1193+
let new_node_dbg =
1194+
session.opts.unstable_opts.incremental_verify_ich || cfg!(debug_assertions);
1195+
11891196
CurrentDepGraph {
11901197
encoder: GraphEncoder::new(
11911198
encoder,
@@ -1207,16 +1214,12 @@ impl<D: Deps> CurrentDepGraph<D> {
12071214
forbidden_edge,
12081215
#[cfg(debug_assertions)]
12091216
fingerprints: Lock::new(IndexVec::from_elem_n(None, new_node_count_estimate)),
1210-
nodes_newly_allocated_in_current_session: session
1211-
.opts
1212-
.unstable_opts
1213-
.incremental_verify_ich
1214-
.then(|| {
1215-
Lock::new(FxHashSet::with_capacity_and_hasher(
1216-
new_node_count_estimate,
1217-
Default::default(),
1218-
))
1219-
}),
1217+
nodes_newly_allocated_in_current_session: new_node_dbg.then(|| {
1218+
Lock::new(FxHashSet::with_capacity_and_hasher(
1219+
new_node_count_estimate,
1220+
Default::default(),
1221+
))
1222+
}),
12201223
total_read_count: AtomicU64::new(0),
12211224
total_duplicate_read_count: AtomicU64::new(0),
12221225
}
@@ -1248,9 +1251,11 @@ impl<D: Deps> CurrentDepGraph<D> {
12481251
if let Some(ref nodes_newly_allocated_in_current_session) =
12491252
self.nodes_newly_allocated_in_current_session
12501253
{
1251-
if !nodes_newly_allocated_in_current_session.lock().insert(key) {
1252-
panic!("Found duplicate dep-node {key:?}");
1253-
}
1254+
outline(|| {
1255+
if !nodes_newly_allocated_in_current_session.lock().insert(key) {
1256+
panic!("Found duplicate dep-node {key:?}");
1257+
}
1258+
});
12541259
}
12551260

12561261
dep_node_index

0 commit comments

Comments
 (0)