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.
This commit is contained in:
Niko Matsakis 2017-04-14 13:27:39 -04:00
parent 8289e5a73e
commit 4c31750cd9
2 changed files with 11 additions and 23 deletions

View File

@ -802,6 +802,7 @@ fn write_metadata<'a, 'gcx>(tcx: TyCtxt<'a, 'gcx, 'gcx>,
/// in any other compilation unit. Give these symbols internal linkage.
fn internalize_symbols<'a, 'tcx>(sess: &Session,
scx: &SharedCrateContext<'a, 'tcx>,
translation_items: &FxHashSet<TransItem<'tcx>>,
llvm_modules: &[ModuleLlvm],
symbol_map: &SymbolMap<'tcx>,
exported_symbols: &ExportedSymbols) {
@ -854,7 +855,7 @@ fn internalize_symbols<'a, 'tcx>(sess: &Session,
let mut locally_defined_symbols = FxHashSet();
let mut linkage_fixed_explicitly = FxHashSet();
for trans_item in scx.translation_items().borrow().iter() {
for trans_item in translation_items {
let symbol_name = symbol_map.get_or_compute(scx, *trans_item);
if trans_item.explicit_linkage(tcx).is_some() {
linkage_fixed_explicitly.insert(symbol_name.clone());
@ -1109,7 +1110,8 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// Run the translation item collector and partition the collected items into
// codegen units.
let (codegen_units, symbol_map) = collect_and_partition_translation_items(&shared_ccx);
let (translation_items, codegen_units, symbol_map) =
collect_and_partition_translation_items(&shared_ccx);
let symbol_map = Rc::new(symbol_map);
@ -1289,6 +1291,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
time(shared_ccx.sess().time_passes(), "internalize symbols", || {
internalize_symbols(sess,
&shared_ccx,
&translation_items,
&llvm_modules,
&symbol_map,
&exported_symbols);
@ -1517,7 +1520,9 @@ fn gather_type_sizes<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) {
}
fn collect_and_partition_translation_items<'a, 'tcx>(scx: &SharedCrateContext<'a, 'tcx>)
-> (Vec<CodegenUnit<'tcx>>, SymbolMap<'tcx>) {
-> (FxHashSet<TransItem<'tcx>>,
Vec<CodegenUnit<'tcx>>,
SymbolMap<'tcx>) {
let time_passes = scx.sess().time_passes();
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
assert!(scx.tcx().sess.opts.cg.codegen_units == codegen_units.len() ||
scx.tcx().sess.opts.debugging_opts.incremental.is_some());
{
let mut ccx_map = scx.translation_items().borrow_mut();
for trans_item in items.iter().cloned() {
ccx_map.insert(trans_item);
}
}
let translation_items: FxHashSet<TransItem<'tcx>> = items.iter().cloned().collect();
if scx.sess().opts.debugging_opts.print_trans_items.is_some() {
let mut item_to_cgus = FxHashMap();
@ -1624,5 +1623,5 @@ fn collect_and_partition_translation_items<'a, 'tcx>(scx: &SharedCrateContext<'a
}
}
(codegen_units, symbol_map)
(translation_items, codegen_units, symbol_map)
}

View File

@ -21,7 +21,6 @@ use declare;
use monomorphize::Instance;
use partitioning::CodegenUnit;
use trans_item::TransItem;
use type_::Type;
use rustc_data_structures::base_n;
use rustc::ty::subst::Substs;
@ -31,7 +30,7 @@ use session::config::NoDebugInfo;
use session::Session;
use session::config;
use symbol_map::SymbolMap;
use util::nodemap::{NodeSet, DefIdMap, FxHashMap, FxHashSet};
use util::nodemap::{NodeSet, DefIdMap, FxHashMap};
use std::ffi::{CStr, CString};
use std::cell::{Cell, RefCell};
@ -87,7 +86,6 @@ pub struct SharedCrateContext<'a, 'tcx: 'a> {
use_dll_storage_attrs: bool,
translation_items: RefCell<FxHashSet<TransItem<'tcx>>>,
trait_cache: RefCell<DepTrackingMap<TraitSelectionCache<'tcx>>>,
project_cache: RefCell<DepTrackingMap<ProjectionCache<'tcx>>>,
}
@ -385,7 +383,6 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> {
tcx: tcx,
check_overflow: check_overflow,
use_dll_storage_attrs: use_dll_storage_attrs,
translation_items: RefCell::new(FxHashSet()),
trait_cache: RefCell::new(DepTrackingMap::new(tcx.dep_graph.clone())),
project_cache: RefCell::new(DepTrackingMap::new(tcx.dep_graph.clone())),
}
@ -430,10 +427,6 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> {
pub fn use_dll_storage_attrs(&self) -> bool {
self.use_dll_storage_attrs
}
pub fn translation_items(&self) -> &RefCell<FxHashSet<TransItem<'tcx>>> {
&self.translation_items
}
}
impl<'tcx> LocalCrateContext<'tcx> {
@ -720,10 +713,6 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> {
&*self.local().symbol_map
}
pub fn translation_items(&self) -> &RefCell<FxHashSet<TransItem<'tcx>>> {
&self.shared.translation_items
}
/// Given the def-id of some item that has no type parameters, make
/// a suitable "empty substs" for it.
pub fn empty_substs_for_def_id(&self, item_def_id: DefId) -> &'tcx Substs<'tcx> {