Skip to content

Commit ee9c669

Browse files
committed
Introduce TaskDepsRef::Replay.
1 parent 3b664d0 commit ee9c669

3 files changed

Lines changed: 18 additions & 5 deletions

File tree

compiler/rustc_interface/src/callbacks.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@ fn track_span_parent(def_id: rustc_span::def_id::LocalDefId) {
2323
// Skip doing anything if we aren't tracking dependencies.
2424
let tracks_deps = match icx.task_deps {
2525
TaskDepsRef::Allow(..) => true,
26-
TaskDepsRef::EvalAlways | TaskDepsRef::Ignore | TaskDepsRef::Forbid => false,
26+
TaskDepsRef::EvalAlways
27+
| TaskDepsRef::Ignore
28+
| TaskDepsRef::Forbid
29+
| TaskDepsRef::Replay => false,
2730
};
2831
if tracks_deps {
2932
let _span = icx.tcx.source_span(def_id);

compiler/rustc_middle/src/dep_graph/graph.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,13 @@ impl DepGraph {
224224
with_deps(TaskDepsRef::Ignore, op)
225225
}
226226

227+
pub fn with_replay<OP, R>(&self, op: OP) -> R
228+
where
229+
OP: FnOnce() -> R,
230+
{
231+
with_deps(TaskDepsRef::Replay, op)
232+
}
233+
227234
/// Used to wrap the deserialization of a query result from disk,
228235
/// This method enforces that no new `DepNodes` are created during
229236
/// query result deserialization.
@@ -462,7 +469,7 @@ impl DepGraph {
462469
// queries. They are re-evaluated unconditionally anyway.
463470
return;
464471
}
465-
TaskDepsRef::Ignore => return,
472+
TaskDepsRef::Ignore | TaskDepsRef::Replay => return,
466473
TaskDepsRef::Forbid => {
467474
// Reading is forbidden in this context. ICE with a useful error message.
468475
panic_on_forbidden_read(data, dep_node_index)
@@ -512,7 +519,7 @@ impl DepGraph {
512519
pub fn record_diagnostic<'tcx>(&self, tcx: TyCtxt<'tcx>, diagnostic: &DiagInner) {
513520
if let Some(ref data) = self.data {
514521
read_deps(|task_deps| match task_deps {
515-
TaskDepsRef::EvalAlways | TaskDepsRef::Ignore => return,
522+
TaskDepsRef::EvalAlways | TaskDepsRef::Ignore | TaskDepsRef::Replay => return,
516523
TaskDepsRef::Forbid | TaskDepsRef::Allow(..) => {
517524
let dep_node_index = data
518525
.encode_side_effect(tcx, QuerySideEffect::Diagnostic(diagnostic.clone()));
@@ -606,7 +613,7 @@ impl DepGraph {
606613
TaskDepsRef::EvalAlways => {
607614
edges.push(DepNodeIndex::FOREVER_RED_NODE);
608615
}
609-
TaskDepsRef::Ignore => {}
616+
TaskDepsRef::Ignore | TaskDepsRef::Replay => {}
610617
TaskDepsRef::Forbid => {
611618
panic!("Cannot summarize when dependencies are not recorded.")
612619
}
@@ -1220,6 +1227,9 @@ pub enum TaskDepsRef<'a> {
12201227
EvalAlways,
12211228
/// New dependencies are ignored. This is also used for `dep_graph.with_ignore`.
12221229
Ignore,
1230+
/// This query has already been marked green, its dependency graph is recorded,
1231+
/// but we need to re-run the code to get its result.
1232+
Replay,
12231233
/// Any attempt to add new dependencies will cause a panic.
12241234
/// This is used when decoding a query result from disk,
12251235
/// to ensure that the decoding process doesn't itself

compiler/rustc_query_impl/src/execution.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ fn load_from_disk_or_invoke_provider_green<'tcx, C: QueryCache>(
529529
// We could not load a result from the on-disk cache, so recompute. The dep-graph for
530530
// this computation is already in-place, so we can just call the query provider.
531531
let prof_timer = tcx.prof.query_provider();
532-
let value = tcx.dep_graph.with_ignore(|| (query.invoke_provider_fn)(tcx, key));
532+
let value = tcx.dep_graph.with_replay(|| (query.invoke_provider_fn)(tcx, key));
533533
prof_timer.finish_with_query_invocation_id(dep_node_index.into());
534534

535535
(value, true)

0 commit comments

Comments
 (0)