Skip to content

Commit af095e8

Browse files
incr.comp.: Improve debug output for work products.
1 parent 7c0a403 commit af095e8

File tree

5 files changed

+28
-8
lines changed

5 files changed

+28
-8
lines changed

src/librustc/dep_graph/graph.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@ impl DepGraph {
157157
}
158158

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

src/librustc/session/config.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,12 @@ impl Options {
489489
self.debugging_opts.query_dep_graph
490490
}
491491

492+
#[inline(always)]
493+
pub fn enable_dep_node_debug_strs(&self) -> bool {
494+
cfg!(debug_assertions) &&
495+
(self.debugging_opts.query_dep_graph || self.debugging_opts.incremental_info)
496+
}
497+
492498
pub fn single_codegen_unit(&self) -> bool {
493499
self.incremental.is_none() ||
494500
self.cg.codegen_units == 1

src/librustc_incremental/persist/load.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ pub fn decode_dep_graph<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
189189
&serialized_dep_graph.nodes,
190190
&dirty_raw_nodes,
191191
&mut clean_work_products,
192-
&mut dirty_work_products);
192+
&mut dirty_work_products,
193+
&work_products);
193194
}
194195
}
195196

@@ -394,7 +395,8 @@ fn process_edge<'a, 'tcx, 'edges>(
394395
nodes: &IndexVec<DepNodeIndex, DepNode>,
395396
dirty_raw_nodes: &DirtyNodes,
396397
clean_work_products: &mut FxHashSet<WorkProductId>,
397-
dirty_work_products: &mut FxHashSet<WorkProductId>)
398+
dirty_work_products: &mut FxHashSet<WorkProductId>,
399+
work_products: &[SerializedWorkProduct])
398400
{
399401
// If the target is dirty, skip the edge. If this is an edge
400402
// that targets a work-product, we can print the blame
@@ -418,9 +420,11 @@ fn process_edge<'a, 'tcx, 'edges>(
418420
format!("{:?}", blame)
419421
};
420422

421-
eprintln!("incremental: module {:?} is dirty because {:?} \
422-
changed or was removed",
423-
wp_id,
423+
let wp = work_products.iter().find(|swp| swp.id == wp_id).unwrap();
424+
425+
eprintln!("incremental: module {:?} is dirty because \
426+
{:?} changed or was removed",
427+
wp.work_product.cgu_name,
424428
blame_str);
425429
}
426430
}

src/librustc_incremental/persist/work_product.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ pub fn save_trans_partition(sess: &Session,
5555
};
5656

5757
let work_product = WorkProduct {
58+
cgu_name: cgu_name.to_string(),
5859
input_hash: partition_hash,
5960
saved_files: saved_files,
6061
};

src/librustc_trans/partitioning.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,14 @@ pub fn partition<'a, 'tcx, I>(scx: &SharedCrateContext<'a, 'tcx>,
270270
(&cgu1.name[..]).cmp(&cgu2.name[..])
271271
});
272272

273+
if scx.sess().opts.enable_dep_node_debug_strs() {
274+
for cgu in &result {
275+
let dep_node = cgu.work_product_dep_node();
276+
scx.tcx().dep_graph.register_dep_node_debug_str(dep_node,
277+
|| cgu.name().to_string());
278+
}
279+
}
280+
273281
result
274282
}
275283

0 commit comments

Comments
 (0)