From 4c31750cd9afc64b0b7c9157b7044eb3e5703054 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Fri, 14 Apr 2017 13:27:39 -0400 Subject: [PATCH] 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. --- src/librustc_trans/base.rs | 21 ++++++++++----------- src/librustc_trans/context.rs | 13 +------------ 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs index cb8022efedb..1420f52819b 100644 --- a/src/librustc_trans/base.rs +++ b/src/librustc_trans/base.rs @@ -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>, 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>, SymbolMap<'tcx>) { + -> (FxHashSet>, + Vec>, + 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> = 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) } diff --git a/src/librustc_trans/context.rs b/src/librustc_trans/context.rs index 1d1921bf7b9..5fd36ecb767 100644 --- a/src/librustc_trans/context.rs +++ b/src/librustc_trans/context.rs @@ -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>>, trait_cache: RefCell>>, project_cache: RefCell>>, } @@ -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>> { - &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>> { - &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> {