1
Fork 0

incr.comp.: Improve debug output for work products.

This commit is contained in:
Michael Woerister 2017-06-23 16:37:12 +02:00
parent 2557800fd6
commit ca0a40396c
5 changed files with 28 additions and 8 deletions

View file

@ -157,9 +157,9 @@ impl DepGraph {
}
#[inline(always)]
pub(super) fn register_dep_node_debug_str<F>(&self,
dep_node: DepNode,
debug_str_gen: F)
pub fn register_dep_node_debug_str<F>(&self,
dep_node: DepNode,
debug_str_gen: F)
where F: FnOnce() -> String
{
let mut dep_node_debug = self.data.dep_node_debug.borrow_mut();
@ -206,6 +206,7 @@ impl DepGraph {
/// previous hash. If it matches up, we can reuse the object file.
#[derive(Clone, Debug, RustcEncodable, RustcDecodable)]
pub struct WorkProduct {
pub cgu_name: String,
/// Extra hash used to decide if work-product is still suitable;
/// note that this is *not* a hash of the work-product itself.
/// See documentation on `WorkProduct` type for an example.

View file

@ -489,6 +489,12 @@ impl Options {
self.debugging_opts.query_dep_graph
}
#[inline(always)]
pub fn enable_dep_node_debug_strs(&self) -> bool {
cfg!(debug_assertions) &&
(self.debugging_opts.query_dep_graph || self.debugging_opts.incremental_info)
}
pub fn single_codegen_unit(&self) -> bool {
self.incremental.is_none() ||
self.cg.codegen_units == 1

View file

@ -189,7 +189,8 @@ pub fn decode_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
&serialized_dep_graph.nodes,
&dirty_raw_nodes,
&mut clean_work_products,
&mut dirty_work_products);
&mut dirty_work_products,
&work_products);
}
}
@ -394,7 +395,8 @@ fn process_edge<'a, 'tcx, 'edges>(
nodes: &IndexVec<DepNodeIndex, DepNode>,
dirty_raw_nodes: &DirtyNodes,
clean_work_products: &mut FxHashSet<WorkProductId>,
dirty_work_products: &mut FxHashSet<WorkProductId>)
dirty_work_products: &mut FxHashSet<WorkProductId>,
work_products: &[SerializedWorkProduct])
{
// If the target is dirty, skip the edge. If this is an edge
// that targets a work-product, we can print the blame
@ -418,9 +420,11 @@ fn process_edge<'a, 'tcx, 'edges>(
format!("{:?}", blame)
};
eprintln!("incremental: module {:?} is dirty because {:?} \
changed or was removed",
wp_id,
let wp = work_products.iter().find(|swp| swp.id == wp_id).unwrap();
eprintln!("incremental: module {:?} is dirty because \
{:?} changed or was removed",
wp.work_product.cgu_name,
blame_str);
}
}

View file

@ -55,6 +55,7 @@ pub fn save_trans_partition(sess: &Session,
};
let work_product = WorkProduct {
cgu_name: cgu_name.to_string(),
input_hash: partition_hash,
saved_files: saved_files,
};

View file

@ -270,6 +270,14 @@ pub fn partition<'a, 'tcx, I>(scx: &SharedCrateContext<'a, 'tcx>,
(&cgu1.name[..]).cmp(&cgu2.name[..])
});
if scx.sess().opts.enable_dep_node_debug_strs() {
for cgu in &result {
let dep_node = cgu.work_product_dep_node();
scx.tcx().dep_graph.register_dep_node_debug_str(dep_node,
|| cgu.name().to_string());
}
}
result
}