/// 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) {
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());
// 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);
time(shared_ccx.sess().time_passes(), "internalize symbols", || {
internalize_symbols(sess,
&shared_ccx,
+ &translation_items,
&llvm_modules,
&symbol_map,
&exported_symbols);
}
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 {
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();
}
}
- (codegen_units, symbol_map)
+ (translation_items, codegen_units, symbol_map)
}
use monomorphize::Instance;
use partitioning::CodegenUnit;
-use trans_item::TransItem;
use type_::Type;
use rustc_data_structures::base_n;
use rustc::ty::subst::Substs;
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};
use_dll_storage_attrs: bool,
- translation_items: RefCell<FxHashSet<TransItem<'tcx>>>,
trait_cache: RefCell<DepTrackingMap<TraitSelectionCache<'tcx>>>,
project_cache: RefCell<DepTrackingMap<ProjectionCache<'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())),
}
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> {
&*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> {