Skip to content

Commit

Permalink
incr.comp.: Use DefPathHash-based DepNodes in the serialized DepGraph…
Browse files Browse the repository at this point in the history
… and remove obsolete DefIdDirectory.
  • Loading branch information
michaelwoerister committed May 31, 2017
1 parent 9da83a8 commit 0cbb8b5
Show file tree
Hide file tree
Showing 6 changed files with 74 additions and 268 deletions.
13 changes: 6 additions & 7 deletions src/librustc_incremental/persist/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@

use rustc::dep_graph::{DepNode, WorkProduct, WorkProductId};
use rustc::hir::def_id::DefIndex;
use rustc::hir::map::DefPathHash;
use rustc::ich::Fingerprint;
use rustc::middle::cstore::EncodedMetadataHash;
use std::sync::Arc;
use rustc_data_structures::fx::FxHashMap;

use super::directory::DefPathIndex;

/// Data for use when recompiling the **current crate**.
#[derive(Debug, RustcEncodable, RustcDecodable)]
pub struct SerializedDepGraph {
Expand All @@ -27,7 +26,7 @@ pub struct SerializedDepGraph {
/// These are output nodes that have no incoming edges. We track
/// these separately so that when we reload all edges, we don't
/// lose track of these nodes.
pub bootstrap_outputs: Vec<DepNode<DefPathIndex>>,
pub bootstrap_outputs: Vec<DepNode<DefPathHash>>,

/// These are hashes of two things:
/// - the HIR nodes in this crate
Expand Down Expand Up @@ -55,14 +54,14 @@ pub struct SerializedDepGraph {
/// outgoing edges from a single source together.
#[derive(Debug, RustcEncodable, RustcDecodable)]
pub struct SerializedEdgeSet {
pub source: DepNode<DefPathIndex>,
pub targets: Vec<DepNode<DefPathIndex>>
pub source: DepNode<DefPathHash>,
pub targets: Vec<DepNode<DefPathHash>>
}

#[derive(Debug, RustcEncodable, RustcDecodable)]
pub struct SerializedHash {
/// def-id of thing being hashed
pub dep_node: DepNode<DefPathIndex>,
pub dep_node: DepNode<DefPathHash>,

/// the hash as of previous compilation, computed by code in
/// `hash` module
Expand Down Expand Up @@ -115,5 +114,5 @@ pub struct SerializedMetadataHashes {
/// is only populated if -Z query-dep-graph is specified. It will be
/// empty otherwise. Importing crates are perfectly happy with just having
/// the DefIndex.
pub index_map: FxHashMap<DefIndex, DefPathIndex>
pub index_map: FxHashMap<DefIndex, DefPathHash>
}
204 changes: 0 additions & 204 deletions src/librustc_incremental/persist/directory.rs

This file was deleted.

12 changes: 8 additions & 4 deletions src/librustc_incremental/persist/dirty_clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
//! previous revision to compare things to.
//!

use super::directory::RetracedDefIdDirectory;
use super::load::DirtyNodes;
use rustc::dep_graph::{DepGraphQuery, DepNode};
use rustc::hir;
Expand All @@ -58,18 +57,23 @@ const LABEL: &'static str = "label";
const CFG: &'static str = "cfg";

pub fn check_dirty_clean_annotations<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
dirty_inputs: &DirtyNodes,
retraced: &RetracedDefIdDirectory) {
dirty_inputs: &DirtyNodes) {
// can't add `#[rustc_dirty]` etc without opting in to this feature
if !tcx.sess.features.borrow().rustc_attrs {
return;
}

let _ignore = tcx.dep_graph.in_ignore();
let def_path_hash_to_def_id = tcx.def_path_hash_to_def_id.as_ref().unwrap();
let dirty_inputs: FxHashSet<DepNode<DefId>> =
dirty_inputs.keys()
.filter_map(|d| retraced.map(d))
.filter_map(|dep_node| {
dep_node.map_def(|def_path_hash| {
def_path_hash_to_def_id.get(def_path_hash).cloned()
})
})
.collect();

let query = tcx.dep_graph.query();
debug!("query-nodes: {:?}", query.nodes());
let krate = tcx.hir.krate();
Expand Down
Loading

0 comments on commit 0cbb8b5

Please sign in to comment.