mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-10 05:53:10 +00:00
incr.comp.: Allow for marking DepKinds as inputs.
This commit is contained in:
parent
3b75a3dfea
commit
25bc69ec20
@ -80,14 +80,28 @@ macro_rules! erase {
|
||||
($x:tt) => ({})
|
||||
}
|
||||
|
||||
macro_rules! anon_attr_to_bool {
|
||||
(anon) => (true)
|
||||
macro_rules! is_anon_attr {
|
||||
(anon) => (true);
|
||||
($attr:ident) => (false);
|
||||
}
|
||||
|
||||
macro_rules! is_input_attr {
|
||||
(input) => (true);
|
||||
($attr:ident) => (false);
|
||||
}
|
||||
|
||||
macro_rules! contains_anon_attr {
|
||||
($($attr:ident),*) => ({$(is_anon_attr!($attr) | )* false});
|
||||
}
|
||||
|
||||
macro_rules! contains_input_attr {
|
||||
($($attr:ident),*) => ({$(is_input_attr!($attr) | )* false});
|
||||
}
|
||||
|
||||
macro_rules! define_dep_nodes {
|
||||
(<$tcx:tt>
|
||||
$(
|
||||
[$($anon:ident)*]
|
||||
[$($attr:ident),* ]
|
||||
$variant:ident $(( $($tuple_arg:tt),* ))*
|
||||
$({ $($struct_arg_name:ident : $struct_arg_ty:ty),* })*
|
||||
,)*
|
||||
@ -105,7 +119,9 @@ macro_rules! define_dep_nodes {
|
||||
match *self {
|
||||
$(
|
||||
DepKind :: $variant => {
|
||||
$(return !anon_attr_to_bool!($anon);)*
|
||||
if contains_anon_attr!($($attr),*) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// tuple args
|
||||
$({
|
||||
@ -126,15 +142,20 @@ macro_rules! define_dep_nodes {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unreachable_code)]
|
||||
#[inline]
|
||||
pub fn is_anon<$tcx>(&self) -> bool {
|
||||
pub fn is_anon(&self) -> bool {
|
||||
match *self {
|
||||
$(
|
||||
DepKind :: $variant => {
|
||||
$(return anon_attr_to_bool!($anon);)*
|
||||
false
|
||||
}
|
||||
DepKind :: $variant => { contains_anon_attr!($($attr),*) }
|
||||
)*
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is_input(&self) -> bool {
|
||||
match *self {
|
||||
$(
|
||||
DepKind :: $variant => { contains_input_attr!($($attr),*) }
|
||||
)*
|
||||
}
|
||||
}
|
||||
@ -378,18 +399,17 @@ define_dep_nodes!( <'tcx>
|
||||
// suitable wrapper, you can use `tcx.dep_graph.ignore()` to gain
|
||||
// access to the krate, but you must remember to add suitable
|
||||
// edges yourself for the individual items that you read.
|
||||
[] Krate,
|
||||
[input] Krate,
|
||||
|
||||
// Represents the HIR node with the given node-id
|
||||
[] Hir(DefId),
|
||||
[input] Hir(DefId),
|
||||
|
||||
// Represents the body of a function or method. The def-id is that of the
|
||||
// function/method.
|
||||
[] HirBody(DefId),
|
||||
[input] HirBody(DefId),
|
||||
|
||||
// Represents the metadata for a given HIR node, typically found
|
||||
// in an extern crate.
|
||||
[] MetaData(DefId),
|
||||
// Represents metadata from an extern crate.
|
||||
[input] MetaData(DefId),
|
||||
|
||||
// Represents some artifact that we save to disk. Note that these
|
||||
// do not have a def-id as part of their identifier.
|
||||
@ -529,7 +549,7 @@ define_dep_nodes!( <'tcx>
|
||||
[] ExternCrate(DefId),
|
||||
[] LintLevels,
|
||||
[] Specializes { impl1: DefId, impl2: DefId },
|
||||
[] InScopeTraits(DefIndex),
|
||||
[input] InScopeTraits(DefIndex),
|
||||
[] ModuleExports(DefId),
|
||||
[] IsSanitizerRuntime(CrateNum),
|
||||
[] IsProfilerRuntime(CrateNum),
|
||||
|
@ -123,6 +123,7 @@ impl DepGraphEdges {
|
||||
reads
|
||||
} = popped_node {
|
||||
debug_assert_eq!(node, key);
|
||||
debug_assert!(!node.kind.is_input() || reads.is_empty());
|
||||
|
||||
let target_id = self.get_or_create_node(node);
|
||||
|
||||
|
@ -45,21 +45,6 @@ impl<'a, 'tcx> HashContext<'a, 'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn is_hashable(tcx: TyCtxt, dep_node: &DepNode) -> bool {
|
||||
match dep_node.kind {
|
||||
DepKind::Krate |
|
||||
DepKind::Hir |
|
||||
DepKind::InScopeTraits |
|
||||
DepKind::HirBody =>
|
||||
true,
|
||||
DepKind::MetaData => {
|
||||
let def_id = dep_node.extract_def_id(tcx).unwrap();
|
||||
!def_id.is_local()
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn hash(&mut self, dep_node: &DepNode) -> Option<Fingerprint> {
|
||||
match dep_node.kind {
|
||||
DepKind::Krate => {
|
||||
@ -79,13 +64,11 @@ impl<'a, 'tcx> HashContext<'a, 'tcx> {
|
||||
// save it for others to use.
|
||||
DepKind::MetaData => {
|
||||
let def_id = dep_node.extract_def_id(self.tcx).unwrap();
|
||||
if !def_id.is_local() {
|
||||
Some(self.metadata_hash(def_id,
|
||||
assert!(!def_id.is_local());
|
||||
|
||||
Some(self.metadata_hash(def_id,
|
||||
def_id.krate,
|
||||
|this| &mut this.metadata_hashes))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
_ => {
|
||||
|
@ -66,7 +66,7 @@ impl<'q> Predecessors<'q> {
|
||||
// Reduce the graph to the most important nodes.
|
||||
let compress::Reduction { graph, input_nodes } =
|
||||
compress::reduce_graph(&query.graph,
|
||||
|n| HashContext::is_hashable(tcx, n),
|
||||
|n| n.kind.is_input(),
|
||||
|n| is_output(n));
|
||||
|
||||
let mut hashes = FxHashMap();
|
||||
|
Loading…
Reference in New Issue
Block a user