1
Fork 0

Represent diagnostic side effects as dep nodes

This commit is contained in:
John Kåre Alsaker 2024-03-07 06:47:08 +01:00
parent f7b4354283
commit 3ca5220114
11 changed files with 138 additions and 180 deletions

View file

@ -79,6 +79,7 @@ rustc_query_append!(define_dep_nodes![
[] fn Null() -> (),
/// We use this to create a forever-red node.
[] fn Red() -> (),
[] fn SideEffect() -> (),
[] fn TraitSelect() -> (),
[] fn CompileCodegenUnit() -> (),
[] fn CompileMonoItem() -> (),

View file

@ -46,6 +46,7 @@ impl Deps for DepsType {
const DEP_KIND_NULL: DepKind = dep_kinds::Null;
const DEP_KIND_RED: DepKind = dep_kinds::Red;
const DEP_KIND_SIDE_EFFECT: DepKind = dep_kinds::SideEffect;
const DEP_KIND_MAX: u16 = dep_node::DEP_KIND_VARIANTS - 1;
}

View file

@ -357,11 +357,10 @@ impl OnDiskCache {
&self,
tcx: TyCtxt<'_>,
dep_node_index: SerializedDepNodeIndex,
) -> QuerySideEffects {
) -> Option<QuerySideEffects> {
let side_effects: Option<QuerySideEffects> =
self.load_indexed(tcx, dep_node_index, &self.prev_side_effects_index);
side_effects.unwrap_or_default()
side_effects
}
/// Stores a `QuerySideEffects` emitted during the current compilation session.
@ -395,21 +394,6 @@ impl OnDiskCache {
opt_value
}
/// Stores side effect emitted during computation of an anonymous query.
/// Since many anonymous queries can share the same `DepNode`, we aggregate
/// them -- as opposed to regular queries where we assume that there is a
/// 1:1 relationship between query-key and `DepNode`.
pub fn store_side_effects_for_anon_node(
&self,
dep_node_index: DepNodeIndex,
side_effects: QuerySideEffects,
) {
let mut current_side_effects = self.current_side_effects.borrow_mut();
let x = current_side_effects.entry(dep_node_index).or_default();
x.append(side_effects);
}
fn load_indexed<'tcx, T>(
&self,
tcx: TyCtxt<'tcx>,

View file

@ -1,8 +1,6 @@
use std::{mem, ptr};
use rustc_data_structures::sync::{self, Lock};
use rustc_errors::DiagInner;
use thin_vec::ThinVec;
use rustc_data_structures::sync;
use super::{GlobalCtxt, TyCtxt};
use crate::dep_graph::TaskDepsRef;
@ -22,10 +20,6 @@ pub struct ImplicitCtxt<'a, 'tcx> {
/// `ty::query::plumbing` when executing a query.
pub query: Option<QueryJobId>,
/// Where to store diagnostics for the current query job, if any.
/// This is updated by `JobOwner::start` in `ty::query::plumbing` when executing a query.
pub diagnostics: Option<&'a Lock<ThinVec<DiagInner>>>,
/// Used to prevent queries from calling too deeply.
pub query_depth: usize,
@ -37,13 +31,7 @@ pub struct ImplicitCtxt<'a, 'tcx> {
impl<'a, 'tcx> ImplicitCtxt<'a, 'tcx> {
pub fn new(gcx: &'tcx GlobalCtxt<'tcx>) -> Self {
let tcx = TyCtxt { gcx };
ImplicitCtxt {
tcx,
query: None,
diagnostics: None,
query_depth: 0,
task_deps: TaskDepsRef::Ignore,
}
ImplicitCtxt { tcx, query: None, query_depth: 0, task_deps: TaskDepsRef::Ignore }
}
}