Skip to content

Commit 91d4f8b

Browse files
Rollup merge of #156175 - nnethercote:dep_graph-cleanups, r=adwinwhite
Dep graph cleanups Minor cleanups I found while looking at dep graph code. Details in individual commits. r? @adwinwhite
2 parents a71746c + 57e0d9d commit 91d4f8b

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

  • compiler/rustc_middle/src/dep_graph

compiler/rustc_middle/src/dep_graph/graph.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -331,16 +331,15 @@ impl DepGraphData {
331331
format!("forcing query with already existing `DepNode`: {dep_node:?}")
332332
});
333333

334-
let with_deps = |task_deps| with_deps(task_deps, op);
335334
let (result, edges) = if tcx.is_eval_always(dep_node.kind) {
336-
(with_deps(TaskDepsRef::EvalAlways), EdgesVec::new())
335+
(with_deps(TaskDepsRef::EvalAlways, op), EdgesVec::new())
337336
} else {
338337
let task_deps = Lock::new(TaskDeps::new(
339338
#[cfg(debug_assertions)]
340339
Some(dep_node),
341340
0,
342341
));
343-
(with_deps(TaskDepsRef::Allow(&task_deps)), task_deps.into_inner().reads)
342+
(with_deps(TaskDepsRef::Allow(&task_deps), op), task_deps.into_inner().reads)
344343
};
345344

346345
let dep_node_index =
@@ -396,10 +395,10 @@ impl DepGraphData {
396395
}
397396
_ => {
398397
// The dep node indices are hashed here instead of hashing the dep nodes of the
399-
// dependencies. These indices may refer to different nodes per session, but this isn't
400-
// a problem here because we that ensure the final dep node hash is per session only by
401-
// combining it with the per session random number `anon_id_seed`. This hash only need
402-
// to map the dependencies to a single value on a per session basis.
398+
// dependencies. These indices may refer to different nodes per session, but this
399+
// isn't a problem here because we that ensure the final dep node hash is per
400+
// session only by combining it with the per session `anon_id_seed`. This hash only
401+
// need to map the dependencies to a single value on a per session basis.
403402
let mut hasher = StableHasher::new();
404403
reads.hash(&mut hasher);
405404

@@ -1223,13 +1222,14 @@ pub struct TaskDeps {
12231222
#[cfg(debug_assertions)]
12241223
node: Option<DepNode>,
12251224

1226-
/// A vector of `DepNodeIndex`, basically.
1225+
/// A vector of `DepNodeIndex`, basically. Contains no duplicates.
12271226
reads: EdgesVec,
12281227

1229-
/// When adding new edges to `reads` in `DepGraph::read_index` we need to determine if the edge
1230-
/// has been seen before. If the number of elements in `reads` is small, we just do a linear
1231-
/// scan. If the number is higher, a hashset has better perf. This field is that hashset. It's
1232-
/// only used if the number of elements in `reads` exceeds `LINEAR_SCAN_MAX`.
1228+
/// When adding a new edge to `reads` in `DepGraph::read_index` we must determine if the edge
1229+
/// has been seen before. We just do a linear scan of `reads` if its length is less than or
1230+
/// equal to `LINEAR_SCAN_MAX`. Otherwise, we use this hashset for better performance. Note:
1231+
/// `reads` is always the canonical edges representation; this field is just to speed up the
1232+
/// seen-before test.
12331233
read_set: FxHashSet<DepNodeIndex>,
12341234
}
12351235

0 commit comments

Comments
 (0)