diff options
| author | bors <bors@rust-lang.org> | 2017-08-02 11:14:54 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-08-02 11:14:54 +0000 |
| commit | 22f256f69e61a0f2ceb7eb842589597f6fe4ce37 (patch) | |
| tree | 1217cc20970a766ece338fda537dc7f63470dddf | |
| parent | 5c385bef7a2429db496f809f2e5042774fe7079b (diff) | |
| parent | b2c3a413b955ac89be06367f4db7706cbd88dc9c (diff) | |
| download | rust-22f256f69e61a0f2ceb7eb842589597f6fe4ce37.tar.gz rust-22f256f69e61a0f2ceb7eb842589597f6fe4ce37.zip | |
Auto merge of #43612 - michaelwoerister:fix-cgu-hashing, r=eddyb
incr.comp.: Properly incorporate symbol linkage and visibility into CGU hash. This PR fixes the way the CGU hash for incr. comp. is computed. The CGU hash represents which `TransItems` are emitted into which codegen unit with which linkage and visibility. Before the new, LLVM-independent symbol internalizer the CGU hash did not accurately contain `TransItem` linkage and visibility because we would not enable symbol internalization in incremental mode anyway. The new internalizer is also run in incremental mode which uncovered the inaccuracy of CGU hashing. Luckily, the fix is rather simple. r? @eddyb cc @nikomatsakis
| -rw-r--r-- | src/librustc_trans/base.rs | 2 | ||||
| -rw-r--r-- | src/librustc_trans/partitioning.rs | 21 |
2 files changed, 5 insertions, 18 deletions
diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs index 14c73de64bc..49a2885747f 100644 --- a/src/librustc_trans/base.rs +++ b/src/librustc_trans/base.rs @@ -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 diff --git a/src/librustc_trans/partitioning.rs b/src/librustc_trans/partitioning.rs index 904cfb2acd7..cff0eca02c6 100644 --- a/src/librustc_trans/partitioning.rs +++ b/src/librustc_trans/partitioning.rs @@ -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() } |
