incr.comp.: Take symbol visibility into account for CGU hashes.
This commit is contained in:
parent
e9aa73d2bf
commit
4a494ed8df
4 changed files with 37 additions and 13 deletions
|
@ -48,6 +48,7 @@ pub mod ich;
|
||||||
pub use assert_dep_graph::assert_dep_graph;
|
pub use assert_dep_graph::assert_dep_graph;
|
||||||
pub use calculate_svh::compute_incremental_hashes_map;
|
pub use calculate_svh::compute_incremental_hashes_map;
|
||||||
pub use calculate_svh::IncrementalHashesMap;
|
pub use calculate_svh::IncrementalHashesMap;
|
||||||
|
pub use calculate_svh::hasher::IchHasher;
|
||||||
pub use persist::load_dep_graph;
|
pub use persist::load_dep_graph;
|
||||||
pub use persist::save_dep_graph;
|
pub use persist::save_dep_graph;
|
||||||
pub use persist::save_trans_partition;
|
pub use persist::save_trans_partition;
|
||||||
|
|
|
@ -1610,7 +1610,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
|
|
||||||
let symbol_map = Rc::new(symbol_map);
|
let symbol_map = Rc::new(symbol_map);
|
||||||
|
|
||||||
let previous_work_products = trans_reuse_previous_work_products(tcx,
|
let previous_work_products = trans_reuse_previous_work_products(&shared_ccx,
|
||||||
&codegen_units,
|
&codegen_units,
|
||||||
&symbol_map);
|
&symbol_map);
|
||||||
|
|
||||||
|
@ -1630,7 +1630,9 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
|
|
||||||
ModuleTranslation {
|
ModuleTranslation {
|
||||||
name: String::from(ccx.codegen_unit().name()),
|
name: String::from(ccx.codegen_unit().name()),
|
||||||
symbol_name_hash: ccx.codegen_unit().compute_symbol_name_hash(tcx, &symbol_map),
|
symbol_name_hash: ccx.codegen_unit()
|
||||||
|
.compute_symbol_name_hash(&shared_ccx,
|
||||||
|
&symbol_map),
|
||||||
source: source,
|
source: source,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -1962,7 +1964,7 @@ fn gather_type_sizes<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
|
||||||
|
|
||||||
/// For each CGU, identify if we can reuse an existing object file (or
|
/// For each CGU, identify if we can reuse an existing object file (or
|
||||||
/// maybe other context).
|
/// maybe other context).
|
||||||
fn trans_reuse_previous_work_products(tcx: TyCtxt,
|
fn trans_reuse_previous_work_products(scx: &SharedCrateContext,
|
||||||
codegen_units: &[CodegenUnit],
|
codegen_units: &[CodegenUnit],
|
||||||
symbol_map: &SymbolMap)
|
symbol_map: &SymbolMap)
|
||||||
-> Vec<Option<WorkProduct>> {
|
-> Vec<Option<WorkProduct>> {
|
||||||
|
@ -1972,16 +1974,16 @@ fn trans_reuse_previous_work_products(tcx: TyCtxt,
|
||||||
.map(|cgu| {
|
.map(|cgu| {
|
||||||
let id = cgu.work_product_id();
|
let id = cgu.work_product_id();
|
||||||
|
|
||||||
let hash = cgu.compute_symbol_name_hash(tcx, symbol_map);
|
let hash = cgu.compute_symbol_name_hash(scx, symbol_map);
|
||||||
|
|
||||||
debug!("trans_reuse_previous_work_products: id={:?} hash={}", id, hash);
|
debug!("trans_reuse_previous_work_products: id={:?} hash={}", id, hash);
|
||||||
|
|
||||||
if let Some(work_product) = tcx.dep_graph.previous_work_product(&id) {
|
if let Some(work_product) = scx.dep_graph().previous_work_product(&id) {
|
||||||
if work_product.input_hash == hash {
|
if work_product.input_hash == hash {
|
||||||
debug!("trans_reuse_previous_work_products: reusing {:?}", work_product);
|
debug!("trans_reuse_previous_work_products: reusing {:?}", work_product);
|
||||||
return Some(work_product);
|
return Some(work_product);
|
||||||
} else {
|
} else {
|
||||||
if tcx.sess.opts.debugging_opts.incremental_info {
|
if scx.sess().opts.debugging_opts.incremental_info {
|
||||||
println!("incremental: CGU `{}` invalidated because of \
|
println!("incremental: CGU `{}` invalidated because of \
|
||||||
changed partitioning hash.",
|
changed partitioning hash.",
|
||||||
cgu.name());
|
cgu.name());
|
||||||
|
|
|
@ -10,7 +10,8 @@
|
||||||
|
|
||||||
use llvm;
|
use llvm;
|
||||||
use llvm::{ContextRef, ModuleRef, ValueRef, BuilderRef};
|
use llvm::{ContextRef, ModuleRef, ValueRef, BuilderRef};
|
||||||
use rustc::dep_graph::{DepNode, DepTrackingMap, DepTrackingMapConfig, WorkProduct};
|
use rustc::dep_graph::{DepGraph, DepNode, DepTrackingMap, DepTrackingMapConfig,
|
||||||
|
WorkProduct};
|
||||||
use middle::cstore::LinkMeta;
|
use middle::cstore::LinkMeta;
|
||||||
use rustc::hir::def::ExportMap;
|
use rustc::hir::def::ExportMap;
|
||||||
use rustc::hir::def_id::DefId;
|
use rustc::hir::def_id::DefId;
|
||||||
|
@ -551,6 +552,10 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> {
|
||||||
&self.tcx.sess
|
&self.tcx.sess
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn dep_graph<'a>(&'a self) -> &'a DepGraph {
|
||||||
|
&self.tcx.dep_graph
|
||||||
|
}
|
||||||
|
|
||||||
pub fn stats<'a>(&'a self) -> &'a Stats {
|
pub fn stats<'a>(&'a self) -> &'a Stats {
|
||||||
&self.stats
|
&self.stats
|
||||||
}
|
}
|
||||||
|
|
|
@ -126,10 +126,10 @@ use rustc::hir::map::DefPathData;
|
||||||
use rustc::session::config::NUMBERED_CODEGEN_UNIT_MARKER;
|
use rustc::session::config::NUMBERED_CODEGEN_UNIT_MARKER;
|
||||||
use rustc::ty::TyCtxt;
|
use rustc::ty::TyCtxt;
|
||||||
use rustc::ty::item_path::characteristic_def_id_of_type;
|
use rustc::ty::item_path::characteristic_def_id_of_type;
|
||||||
|
use rustc_incremental::IchHasher;
|
||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::hash::{Hash, Hasher};
|
use std::hash::Hash;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::collections::hash_map::DefaultHasher;
|
|
||||||
use symbol_map::SymbolMap;
|
use symbol_map::SymbolMap;
|
||||||
use syntax::ast::NodeId;
|
use syntax::ast::NodeId;
|
||||||
use syntax::symbol::{Symbol, InternedString};
|
use syntax::symbol::{Symbol, InternedString};
|
||||||
|
@ -188,14 +188,30 @@ impl<'tcx> CodegenUnit<'tcx> {
|
||||||
DepNode::WorkProduct(self.work_product_id())
|
DepNode::WorkProduct(self.work_product_id())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn compute_symbol_name_hash(&self, tcx: TyCtxt, symbol_map: &SymbolMap) -> u64 {
|
pub fn compute_symbol_name_hash(&self,
|
||||||
let mut state = DefaultHasher::new();
|
scx: &SharedCrateContext,
|
||||||
let all_items = self.items_in_deterministic_order(tcx, symbol_map);
|
symbol_map: &SymbolMap) -> u64 {
|
||||||
|
let mut state = IchHasher::new();
|
||||||
|
let exported_symbols = scx.exported_symbols();
|
||||||
|
let all_items = self.items_in_deterministic_order(scx.tcx(), symbol_map);
|
||||||
for (item, _) in all_items {
|
for (item, _) in all_items {
|
||||||
let symbol_name = symbol_map.get(item).unwrap();
|
let symbol_name = symbol_map.get(item).unwrap();
|
||||||
|
symbol_name.len().hash(&mut state);
|
||||||
symbol_name.hash(&mut state);
|
symbol_name.hash(&mut state);
|
||||||
|
let exported = match item {
|
||||||
|
TransItem::Fn(ref instance) => {
|
||||||
|
let node_id = scx.tcx().map.as_local_node_id(instance.def);
|
||||||
|
node_id.map(|node_id| exported_symbols.contains(&node_id))
|
||||||
|
.unwrap_or(false)
|
||||||
|
}
|
||||||
|
TransItem::Static(node_id) => {
|
||||||
|
exported_symbols.contains(&node_id)
|
||||||
|
}
|
||||||
|
TransItem::DropGlue(..) => false,
|
||||||
|
};
|
||||||
|
exported.hash(&mut state);
|
||||||
}
|
}
|
||||||
state.finish()
|
state.finish().to_smaller_hash()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn items_in_deterministic_order(&self,
|
pub fn items_in_deterministic_order(&self,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue