Skip to content

Commit 4c31750

Browse files
committed
remove translation_items from SharedCrateContext
If we are going to hash `SharedCrateContext`, we don't want a list of things that pertain to **every CGU** in there.
1 parent 8289e5a commit 4c31750

File tree

2 files changed

+11
-23
lines changed

2 files changed

+11
-23
lines changed

src/librustc_trans/base.rs

+10-11
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,7 @@ fn write_metadata<'a, 'gcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>,
802802
/// in any other compilation unit. Give these symbols internal linkage.
803803
fn internalize_symbols<'a, 'tcx>(sess: &Session,
804804
scx: &SharedCrateContext<'a, 'tcx>,
805+
translation_items: &FxHashSet<TransItem<'tcx>>,
805806
llvm_modules: &[ModuleLlvm],
806807
symbol_map: &SymbolMap<'tcx>,
807808
exported_symbols: &ExportedSymbols) {
@@ -854,7 +855,7 @@ fn internalize_symbols<'a, 'tcx>(sess: &Session,
854855
let mut locally_defined_symbols = FxHashSet();
855856
let mut linkage_fixed_explicitly = FxHashSet();
856857

857-
for trans_item in scx.translation_items().borrow().iter() {
858+
for trans_item in translation_items {
858859
let symbol_name = symbol_map.get_or_compute(scx, *trans_item);
859860
if trans_item.explicit_linkage(tcx).is_some() {
860861
linkage_fixed_explicitly.insert(symbol_name.clone());
@@ -1109,7 +1110,8 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
11091110

11101111
// Run the translation item collector and partition the collected items into
11111112
// codegen units.
1112-
let (codegen_units, symbol_map) = collect_and_partition_translation_items(&shared_ccx);
1113+
let (translation_items, codegen_units, symbol_map) =
1114+
collect_and_partition_translation_items(&shared_ccx);
11131115

11141116
let symbol_map = Rc::new(symbol_map);
11151117

@@ -1289,6 +1291,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
12891291
time(shared_ccx.sess().time_passes(), "internalize symbols", || {
12901292
internalize_symbols(sess,
12911293
&shared_ccx,
1294+
&translation_items,
12921295
&llvm_modules,
12931296
&symbol_map,
12941297
&exported_symbols);
@@ -1517,7 +1520,9 @@ fn gather_type_sizes<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
15171520
}
15181521

15191522
fn collect_and_partition_translation_items<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>)
1520-
-> (Vec<CodegenUnit<'tcx>>, SymbolMap<'tcx>) {
1523+
-> (FxHashSet<TransItem<'tcx>>,
1524+
Vec<CodegenUnit<'tcx>>,
1525+
SymbolMap<'tcx>) {
15211526
let time_passes = scx.sess().time_passes();
15221527

15231528
let collection_mode = match scx.sess().opts.debugging_opts.print_trans_items {
@@ -1563,13 +1568,7 @@ fn collect_and_partition_translation_items<'a, 'tcx>(scx: &SharedCrateContext<'a
15631568
assert!(scx.tcx().sess.opts.cg.codegen_units == codegen_units.len() ||
15641569
scx.tcx().sess.opts.debugging_opts.incremental.is_some());
15651570

1566-
{
1567-
let mut ccx_map = scx.translation_items().borrow_mut();
1568-
1569-
for trans_item in items.iter().cloned() {
1570-
ccx_map.insert(trans_item);
1571-
}
1572-
}
1571+
let translation_items: FxHashSet<TransItem<'tcx>> = items.iter().cloned().collect();
15731572

15741573
if scx.sess().opts.debugging_opts.print_trans_items.is_some() {
15751574
let mut item_to_cgus = FxHashMap();
@@ -1624,5 +1623,5 @@ fn collect_and_partition_translation_items<'a, 'tcx>(scx: &SharedCrateContext<'a
16241623
}
16251624
}
16261625

1627-
(codegen_units, symbol_map)
1626+
(translation_items, codegen_units, symbol_map)
16281627
}

src/librustc_trans/context.rs

+1-12
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ use declare;
2121
use monomorphize::Instance;
2222

2323
use partitioning::CodegenUnit;
24-
use trans_item::TransItem;
2524
use type_::Type;
2625
use rustc_data_structures::base_n;
2726
use rustc::ty::subst::Substs;
@@ -31,7 +30,7 @@ use session::config::NoDebugInfo;
3130
use session::Session;
3231
use session::config;
3332
use symbol_map::SymbolMap;
34-
use util::nodemap::{NodeSet, DefIdMap, FxHashMap, FxHashSet};
33+
use util::nodemap::{NodeSet, DefIdMap, FxHashMap};
3534

3635
use std::ffi::{CStr, CString};
3736
use std::cell::{Cell, RefCell};
@@ -87,7 +86,6 @@ pub struct SharedCrateContext<'a, 'tcx: 'a> {
8786

8887
use_dll_storage_attrs: bool,
8988

90-
translation_items: RefCell<FxHashSet<TransItem<'tcx>>>,
9189
trait_cache: RefCell<DepTrackingMap<TraitSelectionCache<'tcx>>>,
9290
project_cache: RefCell<DepTrackingMap<ProjectionCache<'tcx>>>,
9391
}
@@ -385,7 +383,6 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> {
385383
tcx: tcx,
386384
check_overflow: check_overflow,
387385
use_dll_storage_attrs: use_dll_storage_attrs,
388-
translation_items: RefCell::new(FxHashSet()),
389386
trait_cache: RefCell::new(DepTrackingMap::new(tcx.dep_graph.clone())),
390387
project_cache: RefCell::new(DepTrackingMap::new(tcx.dep_graph.clone())),
391388
}
@@ -430,10 +427,6 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> {
430427
pub fn use_dll_storage_attrs(&self) -> bool {
431428
self.use_dll_storage_attrs
432429
}
433-
434-
pub fn translation_items(&self) -> &RefCell<FxHashSet<TransItem<'tcx>>> {
435-
&self.translation_items
436-
}
437430
}
438431

439432
impl<'tcx> LocalCrateContext<'tcx> {
@@ -720,10 +713,6 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> {
720713
&*self.local().symbol_map
721714
}
722715

723-
pub fn translation_items(&self) -> &RefCell<FxHashSet<TransItem<'tcx>>> {
724-
&self.shared.translation_items
725-
}
726-
727716
/// Given the def-id of some item that has no type parameters, make
728717
/// a suitable "empty substs" for it.
729718
pub fn empty_substs_for_def_id(&self, item_def_id: DefId) -> &'tcx Substs<'tcx> {

0 commit comments

Comments
 (0)