Auto merge of #45353 - wesleywiser:untracked_queries, r=michaelwoerister
[incremental] Add support for eval always queries Part of #45238
This commit is contained in:
commit
51456a6808
4 changed files with 94 additions and 17 deletions
|
@ -90,6 +90,11 @@ macro_rules! is_input_attr {
|
||||||
($attr:ident) => (false);
|
($attr:ident) => (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
macro_rules! is_eval_always_attr {
|
||||||
|
(eval_always) => (true);
|
||||||
|
($attr:ident) => (false);
|
||||||
|
}
|
||||||
|
|
||||||
macro_rules! contains_anon_attr {
|
macro_rules! contains_anon_attr {
|
||||||
($($attr:ident),*) => ({$(is_anon_attr!($attr) | )* false});
|
($($attr:ident),*) => ({$(is_anon_attr!($attr) | )* false});
|
||||||
}
|
}
|
||||||
|
@ -98,6 +103,10 @@ macro_rules! contains_input_attr {
|
||||||
($($attr:ident),*) => ({$(is_input_attr!($attr) | )* false});
|
($($attr:ident),*) => ({$(is_input_attr!($attr) | )* false});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
macro_rules! contains_eval_always_attr {
|
||||||
|
($($attr:ident),*) => ({$(is_eval_always_attr!($attr) | )* false});
|
||||||
|
}
|
||||||
|
|
||||||
macro_rules! define_dep_nodes {
|
macro_rules! define_dep_nodes {
|
||||||
(<$tcx:tt>
|
(<$tcx:tt>
|
||||||
$(
|
$(
|
||||||
|
@ -160,6 +169,15 @@ macro_rules! define_dep_nodes {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn is_eval_always(&self) -> bool {
|
||||||
|
match *self {
|
||||||
|
$(
|
||||||
|
DepKind :: $variant => { contains_eval_always_attr!($($attr), *) }
|
||||||
|
)*
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[allow(unreachable_code)]
|
#[allow(unreachable_code)]
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn has_params(&self) -> bool {
|
pub fn has_params(&self) -> bool {
|
||||||
|
@ -447,10 +465,10 @@ define_dep_nodes!( <'tcx>
|
||||||
|
|
||||||
// Represents different phases in the compiler.
|
// Represents different phases in the compiler.
|
||||||
[] RegionScopeTree(DefId),
|
[] RegionScopeTree(DefId),
|
||||||
[] Coherence,
|
[eval_always] Coherence,
|
||||||
[] CoherenceInherentImplOverlapCheck,
|
[eval_always] CoherenceInherentImplOverlapCheck,
|
||||||
[] CoherenceCheckTrait(DefId),
|
[] CoherenceCheckTrait(DefId),
|
||||||
[] PrivacyAccessLevels(CrateNum),
|
[eval_always] PrivacyAccessLevels(CrateNum),
|
||||||
|
|
||||||
// Represents the MIR for a fn; also used as the task node for
|
// Represents the MIR for a fn; also used as the task node for
|
||||||
// things read/modify that MIR.
|
// things read/modify that MIR.
|
||||||
|
@ -467,7 +485,7 @@ define_dep_nodes!( <'tcx>
|
||||||
|
|
||||||
[] Reachability,
|
[] Reachability,
|
||||||
[] MirKeys,
|
[] MirKeys,
|
||||||
[] CrateVariances,
|
[eval_always] CrateVariances,
|
||||||
|
|
||||||
// Nodes representing bits of computed IR in the tcx. Each shared
|
// Nodes representing bits of computed IR in the tcx. Each shared
|
||||||
// table in the tcx (or elsewhere) maps to one of these
|
// table in the tcx (or elsewhere) maps to one of these
|
||||||
|
@ -497,7 +515,7 @@ define_dep_nodes!( <'tcx>
|
||||||
[] DtorckConstraint(DefId),
|
[] DtorckConstraint(DefId),
|
||||||
[] AdtDestructor(DefId),
|
[] AdtDestructor(DefId),
|
||||||
[] AssociatedItemDefIds(DefId),
|
[] AssociatedItemDefIds(DefId),
|
||||||
[] InherentImpls(DefId),
|
[eval_always] InherentImpls(DefId),
|
||||||
[] TypeckBodiesKrate,
|
[] TypeckBodiesKrate,
|
||||||
[] TypeckTables(DefId),
|
[] TypeckTables(DefId),
|
||||||
[] UsedTraitImports(DefId),
|
[] UsedTraitImports(DefId),
|
||||||
|
@ -567,7 +585,7 @@ define_dep_nodes!( <'tcx>
|
||||||
[] IsCompilerBuiltins(CrateNum),
|
[] IsCompilerBuiltins(CrateNum),
|
||||||
[] HasGlobalAllocator(CrateNum),
|
[] HasGlobalAllocator(CrateNum),
|
||||||
[] ExternCrate(DefId),
|
[] ExternCrate(DefId),
|
||||||
[] LintLevels,
|
[eval_always] LintLevels,
|
||||||
[] Specializes { impl1: DefId, impl2: DefId },
|
[] Specializes { impl1: DefId, impl2: DefId },
|
||||||
[input] InScopeTraits(DefIndex),
|
[input] InScopeTraits(DefIndex),
|
||||||
[] ModuleExports(DefId),
|
[] ModuleExports(DefId),
|
||||||
|
@ -626,7 +644,7 @@ define_dep_nodes!( <'tcx>
|
||||||
[] StabilityIndex,
|
[] StabilityIndex,
|
||||||
[] AllCrateNums,
|
[] AllCrateNums,
|
||||||
[] ExportedSymbols(CrateNum),
|
[] ExportedSymbols(CrateNum),
|
||||||
[] CollectAndPartitionTranslationItems,
|
[eval_always] CollectAndPartitionTranslationItems,
|
||||||
[] ExportName(DefId),
|
[] ExportName(DefId),
|
||||||
[] ContainsExternIndicator(DefId),
|
[] ContainsExternIndicator(DefId),
|
||||||
[] IsTranslatedFunction(DefId),
|
[] IsTranslatedFunction(DefId),
|
||||||
|
|
|
@ -199,11 +199,27 @@ impl DepGraph {
|
||||||
-> (R, DepNodeIndex)
|
-> (R, DepNodeIndex)
|
||||||
where C: DepGraphSafe + StableHashingContextProvider<ContextType=HCX>,
|
where C: DepGraphSafe + StableHashingContextProvider<ContextType=HCX>,
|
||||||
R: HashStable<HCX>,
|
R: HashStable<HCX>,
|
||||||
|
{
|
||||||
|
self.with_task_impl(key, cx, arg, task,
|
||||||
|
|data, key| data.borrow_mut().push_task(key),
|
||||||
|
|data, key| data.borrow_mut().pop_task(key))
|
||||||
|
}
|
||||||
|
|
||||||
|
fn with_task_impl<C, A, R, HCX>(&self,
|
||||||
|
key: DepNode,
|
||||||
|
cx: C,
|
||||||
|
arg: A,
|
||||||
|
task: fn(C, A) -> R,
|
||||||
|
push: fn(&RefCell<CurrentDepGraph>, DepNode),
|
||||||
|
pop: fn(&RefCell<CurrentDepGraph>, DepNode) -> DepNodeIndex)
|
||||||
|
-> (R, DepNodeIndex)
|
||||||
|
where C: DepGraphSafe + StableHashingContextProvider<ContextType=HCX>,
|
||||||
|
R: HashStable<HCX>,
|
||||||
{
|
{
|
||||||
if let Some(ref data) = self.data {
|
if let Some(ref data) = self.data {
|
||||||
debug_assert!(!data.colors.borrow().contains_key(&key));
|
debug_assert!(!data.colors.borrow().contains_key(&key));
|
||||||
|
|
||||||
data.current.borrow_mut().push_task(key);
|
push(&data.current, key);
|
||||||
if cfg!(debug_assertions) {
|
if cfg!(debug_assertions) {
|
||||||
profq_msg(ProfileQueriesMsg::TaskBegin(key.clone()))
|
profq_msg(ProfileQueriesMsg::TaskBegin(key.clone()))
|
||||||
};
|
};
|
||||||
|
@ -220,7 +236,7 @@ impl DepGraph {
|
||||||
profq_msg(ProfileQueriesMsg::TaskEnd)
|
profq_msg(ProfileQueriesMsg::TaskEnd)
|
||||||
};
|
};
|
||||||
|
|
||||||
let dep_node_index = data.current.borrow_mut().pop_task(key);
|
let dep_node_index = pop(&data.current, key);
|
||||||
|
|
||||||
let mut stable_hasher = StableHasher::new();
|
let mut stable_hasher = StableHasher::new();
|
||||||
result.hash_stable(&mut hcx, &mut stable_hasher);
|
result.hash_stable(&mut hcx, &mut stable_hasher);
|
||||||
|
@ -290,6 +306,22 @@ impl DepGraph {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Execute something within an "eval-always" task which is a task
|
||||||
|
// that runs whenever anything changes.
|
||||||
|
pub fn with_eval_always_task<C, A, R, HCX>(&self,
|
||||||
|
key: DepNode,
|
||||||
|
cx: C,
|
||||||
|
arg: A,
|
||||||
|
task: fn(C, A) -> R)
|
||||||
|
-> (R, DepNodeIndex)
|
||||||
|
where C: DepGraphSafe + StableHashingContextProvider<ContextType=HCX>,
|
||||||
|
R: HashStable<HCX>,
|
||||||
|
{
|
||||||
|
self.with_task_impl(key, cx, arg, task,
|
||||||
|
|data, key| data.borrow_mut().push_eval_always_task(key),
|
||||||
|
|data, key| data.borrow_mut().pop_eval_always_task(key))
|
||||||
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn read(&self, v: DepNode) {
|
pub fn read(&self, v: DepNode) {
|
||||||
if let Some(ref data) = self.data {
|
if let Some(ref data) = self.data {
|
||||||
|
@ -788,6 +820,24 @@ impl CurrentDepGraph {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn push_eval_always_task(&mut self, key: DepNode) {
|
||||||
|
self.task_stack.push(OpenTask::EvalAlways { node: key });
|
||||||
|
}
|
||||||
|
|
||||||
|
fn pop_eval_always_task(&mut self, key: DepNode) -> DepNodeIndex {
|
||||||
|
let popped_node = self.task_stack.pop().unwrap();
|
||||||
|
|
||||||
|
if let OpenTask::EvalAlways {
|
||||||
|
node,
|
||||||
|
} = popped_node {
|
||||||
|
debug_assert_eq!(node, key);
|
||||||
|
let krate_idx = self.node_to_node_index[&DepNode::new_no_params(DepKind::Krate)];
|
||||||
|
self.alloc_node(node, vec![krate_idx])
|
||||||
|
} else {
|
||||||
|
bug!("pop_eval_always_task() - Expected eval always task to be popped");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn read_index(&mut self, source: DepNodeIndex) {
|
fn read_index(&mut self, source: DepNodeIndex) {
|
||||||
match self.task_stack.last_mut() {
|
match self.task_stack.last_mut() {
|
||||||
Some(&mut OpenTask::Regular {
|
Some(&mut OpenTask::Regular {
|
||||||
|
@ -818,7 +868,8 @@ impl CurrentDepGraph {
|
||||||
reads.push(source);
|
reads.push(source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(&mut OpenTask::Ignore) | None => {
|
Some(&mut OpenTask::Ignore) |
|
||||||
|
Some(&mut OpenTask::EvalAlways { .. }) | None => {
|
||||||
// ignore
|
// ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -851,4 +902,7 @@ enum OpenTask {
|
||||||
read_set: FxHashSet<DepNodeIndex>,
|
read_set: FxHashSet<DepNodeIndex>,
|
||||||
},
|
},
|
||||||
Ignore,
|
Ignore,
|
||||||
|
EvalAlways {
|
||||||
|
node: DepNode,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -433,10 +433,17 @@ macro_rules! define_maps {
|
||||||
profq_msg!(tcx, ProfileQueriesMsg::ProviderBegin);
|
profq_msg!(tcx, ProfileQueriesMsg::ProviderBegin);
|
||||||
let res = tcx.cycle_check(span, Query::$name(key), || {
|
let res = tcx.cycle_check(span, Query::$name(key), || {
|
||||||
tcx.sess.diagnostic().track_diagnostics(|| {
|
tcx.sess.diagnostic().track_diagnostics(|| {
|
||||||
tcx.dep_graph.with_task(dep_node,
|
if dep_node.kind.is_eval_always() {
|
||||||
tcx,
|
tcx.dep_graph.with_eval_always_task(dep_node,
|
||||||
key,
|
tcx,
|
||||||
Self::compute_result)
|
key,
|
||||||
|
Self::compute_result)
|
||||||
|
} else {
|
||||||
|
tcx.dep_graph.with_task(dep_node,
|
||||||
|
tcx,
|
||||||
|
key,
|
||||||
|
Self::compute_result)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})?;
|
})?;
|
||||||
profq_msg!(tcx, ProfileQueriesMsg::ProviderEnd);
|
profq_msg!(tcx, ProfileQueriesMsg::ProviderEnd);
|
||||||
|
|
|
@ -1563,9 +1563,7 @@ pub fn provide(providers: &mut Providers) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Rc<AccessLevels> {
|
pub fn check_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Rc<AccessLevels> {
|
||||||
tcx.dep_graph.with_ignore(|| { // FIXME
|
tcx.privacy_access_levels(LOCAL_CRATE)
|
||||||
tcx.privacy_access_levels(LOCAL_CRATE)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn privacy_access_levels<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
fn privacy_access_levels<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue