1
Fork 0

Stream the dep-graph to a file.

This commit is contained in:
Camille GILLOT 2021-03-02 22:38:49 +01:00
parent 16156fb278
commit 6bfaf3a9cb
18 changed files with 710 additions and 918 deletions

View file

@ -1,6 +1,8 @@
//! Code for debugging the dep-graph.
use super::{DepKind, DepNode};
use super::{DepKind, DepNode, DepNodeIndex};
use rustc_data_structures::fx::FxHashMap;
use rustc_data_structures::sync::Lock;
use std::error::Error;
/// A dep-node filter goes from a user-defined string to a query over
@ -34,13 +36,14 @@ impl DepNodeFilter {
/// A filter like `F -> G` where `F` and `G` are valid dep-node
/// filters. This can be used to test the source/target independently.
pub struct EdgeFilter {
pub struct EdgeFilter<K: DepKind> {
pub source: DepNodeFilter,
pub target: DepNodeFilter,
pub index_to_node: Lock<FxHashMap<DepNodeIndex, DepNode<K>>>,
}
impl EdgeFilter {
pub fn new(test: &str) -> Result<EdgeFilter, Box<dyn Error>> {
impl<K: DepKind> EdgeFilter<K> {
pub fn new(test: &str) -> Result<EdgeFilter<K>, Box<dyn Error>> {
let parts: Vec<_> = test.split("->").collect();
if parts.len() != 2 {
Err(format!("expected a filter like `a&b -> c&d`, not `{}`", test).into())
@ -48,12 +51,13 @@ impl EdgeFilter {
Ok(EdgeFilter {
source: DepNodeFilter::new(parts[0]),
target: DepNodeFilter::new(parts[1]),
index_to_node: Lock::new(FxHashMap::default()),
})
}
}
#[cfg(debug_assertions)]
pub fn test<K: DepKind>(&self, source: &DepNode<K>, target: &DepNode<K>) -> bool {
pub fn test(&self, source: &DepNode<K>, target: &DepNode<K>) -> bool {
self.source.test(source) && self.target.test(target)
}
}