Rollup merge of #38113 - nikomatsakis:incremental-dump-hash, r=michaelwoerister

add a `-Z incremental-dump-hash` flag

This causes us to dump a bunch of has information to stdout that can be
useful in tracking down incremental compilation invalidations,
particularly across crates.
This commit is contained in:
Corey Farwell 2016-12-03 15:39:53 -05:00 committed by GitHub
commit d6281faf7e
3 changed files with 30 additions and 0 deletions

View File

@ -886,6 +886,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
"enable incremental compilation (experimental)"),
incremental_info: bool = (false, parse_bool, [UNTRACKED],
"print high-level information about incremental reuse (or the lack thereof)"),
incremental_dump_hash: bool = (false, parse_bool, [UNTRACKED],
"dump hash information in textual format to stdout"),
dump_dep_graph: bool = (false, parse_bool, [UNTRACKED],
"dump the dependency graph to $RUST_DEP_GRAPH (default: /tmp/dep_graph.gv)"),
query_dep_graph: bool = (false, parse_bool, [UNTRACKED],

View File

@ -255,11 +255,24 @@ fn dirty_nodes<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
current_hash);
continue;
}
if tcx.sess.opts.debugging_opts.incremental_dump_hash {
println!("node {:?} is dirty as hash is {:?} was {:?}",
dep_node.map_def(|&def_id| Some(tcx.def_path(def_id))).unwrap(),
current_hash,
hash.hash);
}
debug!("initial_dirty_nodes: {:?} is dirty as hash is {:?}, was {:?}",
dep_node.map_def(|&def_id| Some(tcx.def_path(def_id))).unwrap(),
current_hash,
hash.hash);
} else {
if tcx.sess.opts.debugging_opts.incremental_dump_hash {
println!("node {:?} is dirty as it was removed",
hash.dep_node);
}
debug!("initial_dirty_nodes: {:?} is dirty as it was removed",
hash.dep_node);
}

View File

@ -159,6 +159,12 @@ pub fn encode_dep_graph(preds: &Predecessors,
}
}
if tcx.sess.opts.debugging_opts.incremental_dump_hash {
for (dep_node, hash) in &preds.hashes {
println!("HIR hash for {:?} is {}", dep_node, hash);
}
}
// Create the serialized dep-graph.
let graph = SerializedDepGraph {
edges: edges,
@ -248,6 +254,15 @@ pub fn encode_metadata_hashes(tcx: TyCtxt,
let hash = state.finish();
debug!("save: metadata hash for {:?} is {}", def_id, hash);
if tcx.sess.opts.debugging_opts.incremental_dump_hash {
println!("metadata hash for {:?} is {}", def_id, hash);
for dep_node in sources {
println!("metadata hash for {:?} depends on {:?} with hash {}",
def_id, dep_node, preds.hashes[dep_node]);
}
}
serialized_hashes.hashes.push(SerializedMetadataHash {
def_index: def_id.index,
hash: hash,