Skip to content

Commit 22f256f

Browse files
committed
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
2 parents 5c385be + b2c3a41 commit 22f256f

File tree

2 files changed

+5
-18
lines changed

2 files changed

+5
-18
lines changed

src/librustc_trans/base.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1172,7 +1172,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
11721172

11731173
let cgu_name = String::from(cgu.name());
11741174
let cgu_id = cgu.work_product_id();
1175-
let symbol_name_hash = cgu.compute_symbol_name_hash(scx, &exported_symbols);
1175+
let symbol_name_hash = cgu.compute_symbol_name_hash(scx);
11761176

11771177
// Check whether there is a previous work-product we can
11781178
// re-use. Not only must the file exist, and the inputs not

src/librustc_trans/partitioning.rs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -174,29 +174,16 @@ impl<'tcx> CodegenUnit<'tcx> {
174174
}
175175

176176
pub fn compute_symbol_name_hash<'a>(&self,
177-
scx: &SharedCrateContext<'a, 'tcx>,
178-
exported_symbols: &ExportedSymbols)
177+
scx: &SharedCrateContext<'a, 'tcx>)
179178
-> u64 {
180179
let mut state = IchHasher::new();
181-
let exported_symbols = exported_symbols.local_exports();
182180
let all_items = self.items_in_deterministic_order(scx.tcx());
183-
for (item, _) in all_items {
181+
for (item, (linkage, visibility)) in all_items {
184182
let symbol_name = item.symbol_name(scx.tcx());
185183
symbol_name.len().hash(&mut state);
186184
symbol_name.hash(&mut state);
187-
let exported = match item {
188-
TransItem::Fn(ref instance) => {
189-
let node_id =
190-
scx.tcx().hir.as_local_node_id(instance.def_id());
191-
node_id.map(|node_id| exported_symbols.contains(&node_id))
192-
.unwrap_or(false)
193-
}
194-
TransItem::Static(node_id) => {
195-
exported_symbols.contains(&node_id)
196-
}
197-
TransItem::GlobalAsm(..) => true,
198-
};
199-
exported.hash(&mut state);
185+
linkage.hash(&mut state);
186+
visibility.hash(&mut state);
200187
}
201188
state.finish().to_smaller_hash()
202189
}

0 commit comments

Comments
 (0)