incr.comp.: Properly incorporate symbol linkage and visibility into CGU hash.

This commit is contained in:
Michael Woerister 2017-08-02 11:56:23 +02:00
parent 0b5c0874b8
commit b2c3a413b9
2 changed files with 5 additions and 18 deletions

View File

@ -1172,7 +1172,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
let cgu_name = String::from(cgu.name());
let cgu_id = cgu.work_product_id();
let symbol_name_hash = cgu.compute_symbol_name_hash(scx, &exported_symbols);
let symbol_name_hash = cgu.compute_symbol_name_hash(scx);
// Check whether there is a previous work-product we can
// re-use. Not only must the file exist, and the inputs not

View File

@ -174,29 +174,16 @@ impl<'tcx> CodegenUnit<'tcx> {
}
pub fn compute_symbol_name_hash<'a>(&self,
scx: &SharedCrateContext<'a, 'tcx>,
exported_symbols: &ExportedSymbols)
scx: &SharedCrateContext<'a, 'tcx>)
-> u64 {
let mut state = IchHasher::new();
let exported_symbols = exported_symbols.local_exports();
let all_items = self.items_in_deterministic_order(scx.tcx());
for (item, _) in all_items {
for (item, (linkage, visibility)) in all_items {
let symbol_name = item.symbol_name(scx.tcx());
symbol_name.len().hash(&mut state);
symbol_name.hash(&mut state);
let exported = match item {
TransItem::Fn(ref instance) => {
let node_id =
scx.tcx().hir.as_local_node_id(instance.def_id());
node_id.map(|node_id| exported_symbols.contains(&node_id))
.unwrap_or(false)
}
TransItem::Static(node_id) => {
exported_symbols.contains(&node_id)
}
TransItem::GlobalAsm(..) => true,
};
exported.hash(&mut state);
linkage.hash(&mut state);
visibility.hash(&mut state);
}
state.finish().to_smaller_hash()
}