diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index 822fb4d6770f0..34224b924b948 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -329,7 +329,7 @@ pub trait CrateStore<'tcx> { fn crate_disambiguator(&self, cnum: CrateNum) -> Symbol; fn plugin_registrar_fn(&self, cnum: CrateNum) -> Option; fn native_libraries(&self, cnum: CrateNum) -> Vec; - fn reachable_ids(&self, cnum: CrateNum) -> Vec; + fn exported_symbols(&self, cnum: CrateNum) -> Vec; fn is_no_builtins(&self, cnum: CrateNum) -> bool; // resolve @@ -493,7 +493,7 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore { { bug!("plugin_registrar_fn") } fn native_libraries(&self, cnum: CrateNum) -> Vec { bug!("native_libraries") } - fn reachable_ids(&self, cnum: CrateNum) -> Vec { bug!("reachable_ids") } + fn exported_symbols(&self, cnum: CrateNum) -> Vec { bug!("exported_symbols") } fn is_no_builtins(&self, cnum: CrateNum) -> bool { bug!("is_no_builtins") } // resolve diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index 3150f74e61e7c..2965e545eca4e 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -311,9 +311,9 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore { self.get_crate_data(cnum).get_native_libraries() } - fn reachable_ids(&self, cnum: CrateNum) -> Vec + fn exported_symbols(&self, cnum: CrateNum) -> Vec { - self.get_crate_data(cnum).get_reachable_ids() + self.get_crate_data(cnum).get_exported_symbols() } fn is_no_builtins(&self, cnum: CrateNum) -> bool { diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index fe536b69c61d5..43635eae76c0f 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -1038,8 +1038,8 @@ impl<'a, 'tcx> CrateMetadata { arg_names.decode(self).collect() } - pub fn get_reachable_ids(&self) -> Vec { - self.root.reachable_ids.decode(self).map(|index| self.local_def_id(index)).collect() + pub fn get_exported_symbols(&self) -> Vec { + self.root.exported_symbols.decode(self).map(|index| self.local_def_id(index)).collect() } pub fn get_macro(&self, id: DefIndex) -> (ast::Name, MacroDef) { diff --git a/src/librustc_metadata/encoder.rs b/src/librustc_metadata/encoder.rs index 83904b24de328..01cb0f823e8ef 100644 --- a/src/librustc_metadata/encoder.rs +++ b/src/librustc_metadata/encoder.rs @@ -50,7 +50,7 @@ pub struct EncodeContext<'a, 'tcx: 'a> { reexports: &'a def::ExportMap, link_meta: &'a LinkMeta, cstore: &'a cstore::CStore, - reachable: &'a NodeSet, + exported_symbols: &'a NodeSet, lazy_state: LazyState, type_shorthands: FxHashMap, usize>, @@ -1223,16 +1223,16 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { self.lazy_seq(all_impls) } - // Encodes all reachable symbols in this crate into the metadata. + // Encodes all symbols exported from this crate into the metadata. // // This pass is seeded off the reachability list calculated in the // middle::reachable module but filters out items that either don't have a // symbol associated with them (they weren't translated) or if they're an FFI // definition (as that's not defined in this crate). - fn encode_reachable(&mut self) -> LazySeq { - let reachable = self.reachable; + fn encode_exported_symbols(&mut self) -> LazySeq { + let exported_symbols = self.exported_symbols; let tcx = self.tcx; - self.lazy_seq(reachable.iter().map(|&id| tcx.map.local_def_id(id).index)) + self.lazy_seq(exported_symbols.iter().map(|&id| tcx.map.local_def_id(id).index)) } fn encode_dylib_dependency_formats(&mut self) -> LazySeq> { @@ -1278,10 +1278,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { let impls = self.encode_impls(); let impl_bytes = self.position() - i; - // Encode reachability info. + // Encode exported symbols info. i = self.position(); - let reachable_ids = self.encode_reachable(); - let reachable_bytes = self.position() - i; + let exported_symbols = self.encode_exported_symbols(); + let exported_symbols_bytes = self.position() - i; // Encode and index the items. i = self.position(); @@ -1319,7 +1319,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { native_libraries: native_libraries, codemap: codemap, impls: impls, - reachable_ids: reachable_ids, + exported_symbols: exported_symbols, index: index, }); @@ -1339,7 +1339,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> { println!(" native bytes: {}", native_lib_bytes); println!(" codemap bytes: {}", codemap_bytes); println!(" impl bytes: {}", impl_bytes); - println!(" reachable bytes: {}", reachable_bytes); + println!(" exp. symbols bytes: {}", exported_symbols_bytes); println!(" item bytes: {}", item_bytes); println!(" index bytes: {}", index_bytes); println!(" zero bytes: {}", zero_bytes); @@ -1377,7 +1377,7 @@ pub fn encode_metadata<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, cstore: &cstore::CStore, reexports: &def::ExportMap, link_meta: &LinkMeta, - reachable: &NodeSet) + exported_symbols: &NodeSet) -> Vec { let mut cursor = Cursor::new(vec![]); cursor.write_all(METADATA_HEADER).unwrap(); @@ -1392,7 +1392,7 @@ pub fn encode_metadata<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, reexports: reexports, link_meta: link_meta, cstore: cstore, - reachable: reachable, + exported_symbols: exported_symbols, lazy_state: LazyState::NoNode, type_shorthands: Default::default(), predicate_shorthands: Default::default(), diff --git a/src/librustc_metadata/schema.rs b/src/librustc_metadata/schema.rs index 00c3709435de5..f92051cbf1943 100644 --- a/src/librustc_metadata/schema.rs +++ b/src/librustc_metadata/schema.rs @@ -180,7 +180,7 @@ pub struct CrateRoot { pub native_libraries: LazySeq, pub codemap: LazySeq, pub impls: LazySeq, - pub reachable_ids: LazySeq, + pub exported_symbols: LazySeq, pub index: LazySeq, } diff --git a/src/librustc_trans/back/linker.rs b/src/librustc_trans/back/linker.rs index 860903d259fe5..b8d5fc9042f10 100644 --- a/src/librustc_trans/back/linker.rs +++ b/src/librustc_trans/back/linker.rs @@ -34,10 +34,10 @@ pub struct LinkerInfo { impl<'a, 'tcx> LinkerInfo { pub fn new(scx: &SharedCrateContext<'a, 'tcx>, - reachable: &[String]) -> LinkerInfo { + exports: &[String]) -> LinkerInfo { LinkerInfo { exports: scx.sess().crate_types.borrow().iter().map(|&c| { - (c, exported_symbols(scx, reachable, c)) + (c, exported_symbols(scx, exports, c)) }).collect(), } } @@ -473,7 +473,7 @@ impl<'a> Linker for MsvcLinker<'a> { } fn exported_symbols(scx: &SharedCrateContext, - reachable: &[String], + exported_symbols: &[String], crate_type: CrateType) -> Vec { // See explanation in GnuLinker::export_symbols, for @@ -485,7 +485,7 @@ fn exported_symbols(scx: &SharedCrateContext, } } - let mut symbols = reachable.to_vec(); + let mut symbols = exported_symbols.to_vec(); // If we're producing anything other than a dylib then the `reachable` array // above is the exhaustive set of symbols we should be exporting. @@ -507,7 +507,7 @@ fn exported_symbols(scx: &SharedCrateContext, None } }).flat_map(|cnum| { - cstore.reachable_ids(cnum) + cstore.exported_symbols(cnum) }).map(|did| -> String { Instance::mono(scx, did).symbol_name(scx) })); diff --git a/src/librustc_trans/back/lto.rs b/src/librustc_trans/back/lto.rs index 522864c6ec3a4..46b1241de368f 100644 --- a/src/librustc_trans/back/lto.rs +++ b/src/librustc_trans/back/lto.rs @@ -25,7 +25,7 @@ use std::ffi::CString; use std::path::Path; pub fn run(sess: &session::Session, llmod: ModuleRef, - tm: TargetMachineRef, reachable: &[String], + tm: TargetMachineRef, exported_symbols: &[String], config: &ModuleConfig, temp_no_opt_bc_filename: &Path) { if sess.opts.cg.prefer_dynamic { @@ -118,8 +118,8 @@ pub fn run(sess: &session::Session, llmod: ModuleRef, } }); - // Internalize everything but the reachable symbols of the current module - let cstrs: Vec = reachable.iter().map(|s| { + // Internalize everything but the exported symbols of the current module + let cstrs: Vec = exported_symbols.iter().map(|s| { CString::new(s.clone()).unwrap() }).collect(); let arr: Vec<*const libc::c_char> = cstrs.iter().map(|c| c.as_ptr()).collect(); diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs index ae5d02c7e048a..84bba64dd70b2 100644 --- a/src/librustc_trans/back/write.rs +++ b/src/librustc_trans/back/write.rs @@ -343,9 +343,9 @@ struct CodegenContext<'a> { } impl<'a> CodegenContext<'a> { - fn new_with_session(sess: &'a Session, reachable: &'a [String]) -> CodegenContext<'a> { + fn new_with_session(sess: &'a Session, exported_symbols: &'a [String]) -> CodegenContext<'a> { CodegenContext { - lto_ctxt: Some((sess, reachable)), + lto_ctxt: Some((sess, exported_symbols)), handler: sess.diagnostic(), plugin_passes: sess.plugin_llvm_passes.borrow().clone(), remark: sess.opts.cg.remark.clone(), @@ -516,14 +516,14 @@ unsafe fn optimize_and_codegen(cgcx: &CodegenContext, llvm::LLVMDisposePassManager(mpm); match cgcx.lto_ctxt { - Some((sess, reachable)) if sess.lto() => { + Some((sess, exported_symbols)) if sess.lto() => { time(sess.time_passes(), "all lto passes", || { let temp_no_opt_bc_filename = output_names.temp_path_ext("no-opt.lto.bc", module_name); lto::run(sess, llmod, tm, - reachable, + exported_symbols, &config, &temp_no_opt_bc_filename); }); @@ -753,7 +753,7 @@ pub fn run_passes(sess: &Session, // potentially create hundreds of them). let num_workers = work_items.len() - 1; if num_workers == 1 { - run_work_singlethreaded(sess, &trans.reachable, work_items); + run_work_singlethreaded(sess, &trans.exported_symbols, work_items); } else { run_work_multithreaded(sess, work_items, num_workers); } @@ -997,9 +997,9 @@ fn execute_work_item(cgcx: &CodegenContext, } fn run_work_singlethreaded(sess: &Session, - reachable: &[String], + exported_symbols: &[String], work_items: Vec) { - let cgcx = CodegenContext::new_with_session(sess, reachable); + let cgcx = CodegenContext::new_with_session(sess, exported_symbols); // Since we're running single-threaded, we can pass the session to // the proc, allowing `optimize_and_codegen` to perform LTO. diff --git a/src/librustc_trans/base.rs b/src/librustc_trans/base.rs index 259ef2a780cc2..74e6a1dac80b1 100644 --- a/src/librustc_trans/base.rs +++ b/src/librustc_trans/base.rs @@ -1243,7 +1243,7 @@ fn contains_null(s: &str) -> bool { } fn write_metadata(cx: &SharedCrateContext, - reachable_ids: &NodeSet) -> Vec { + exported_symbols: &NodeSet) -> Vec { use flate; #[derive(PartialEq, Eq, PartialOrd, Ord)] @@ -1275,7 +1275,7 @@ fn write_metadata(cx: &SharedCrateContext, let metadata = cstore.encode_metadata(cx.tcx(), cx.export_map(), cx.link_meta(), - reachable_ids); + exported_symbols); if kind == MetadataKind::Uncompressed { return metadata; } @@ -1313,7 +1313,7 @@ fn write_metadata(cx: &SharedCrateContext, fn internalize_symbols<'a, 'tcx>(sess: &Session, ccxs: &CrateContextList<'a, 'tcx>, symbol_map: &SymbolMap<'tcx>, - reachable: &FxHashSet<&str>) { + exported_symbols: &FxHashSet<&str>) { let scx = ccxs.shared(); let tcx = scx.tcx(); @@ -1379,7 +1379,7 @@ fn internalize_symbols<'a, 'tcx>(sess: &Session, let name_cow = Cow::Borrowed(name_str); let is_referenced_somewhere = referenced_somewhere.contains(&name_cstr); - let is_reachable = reachable.contains(&name_str); + let is_reachable = exported_symbols.contains(&name_str); let has_fixed_linkage = linkage_fixed_explicitly.contains(&name_cow); if !is_referenced_somewhere && !is_reachable && !has_fixed_linkage { @@ -1481,7 +1481,7 @@ fn iter_functions(llmod: llvm::ModuleRef) -> ValueIter { /// /// This list is later used by linkers to determine the set of symbols needed to /// be exposed from a dynamic library and it's also encoded into the metadata. -pub fn filter_reachable_ids(tcx: TyCtxt, reachable: NodeSet) -> NodeSet { +pub fn find_exported_symbols(tcx: TyCtxt, reachable: NodeSet) -> NodeSet { reachable.into_iter().filter(|&id| { // Next, we want to ignore some FFI functions that are not exposed from // this crate. Reachable FFI functions can be lumped into two @@ -1535,7 +1535,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let krate = tcx.map.krate(); let ty::CrateAnalysis { export_map, reachable, name, .. } = analysis; - let reachable = filter_reachable_ids(tcx, reachable); + let exported_symbols = find_exported_symbols(tcx, reachable); let check_overflow = if let Some(v) = tcx.sess.opts.debugging_opts.force_overflow_checks { v @@ -1548,11 +1548,11 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, let shared_ccx = SharedCrateContext::new(tcx, export_map, link_meta.clone(), - reachable, + exported_symbols, check_overflow); // Translate the metadata. let metadata = time(tcx.sess.time_passes(), "write metadata", || { - write_metadata(&shared_ccx, shared_ccx.reachable()) + write_metadata(&shared_ccx, shared_ccx.exported_symbols()) }); let metadata_module = ModuleTranslation { @@ -1608,7 +1608,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, metadata_module: metadata_module, link: link_meta, metadata: metadata, - reachable: vec![], + exported_symbols: vec![], no_builtins: no_builtins, linker_info: linker_info, windows_subsystem: None, @@ -1688,17 +1688,17 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, } let sess = shared_ccx.sess(); - let mut reachable_symbols = shared_ccx.reachable().iter().map(|&id| { + let mut exported_symbols = shared_ccx.exported_symbols().iter().map(|&id| { let def_id = shared_ccx.tcx().map.local_def_id(id); symbol_for_def_id(def_id, &shared_ccx, &symbol_map) }).collect::>(); if sess.entry_fn.borrow().is_some() { - reachable_symbols.push("main".to_string()); + exported_symbols.push("main".to_string()); } if sess.crate_types.borrow().contains(&config::CrateTypeDylib) { - reachable_symbols.push(shared_ccx.metadata_symbol_name()); + exported_symbols.push(shared_ccx.metadata_symbol_name()); } // For the purposes of LTO or when creating a cdylib, we add to the @@ -1708,10 +1708,10 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // // Note that this happens even if LTO isn't requested or we're not creating // a cdylib. In those cases, though, we're not even reading the - // `reachable_symbols` list later on so it should be ok. + // `exported_symbols` list later on so it should be ok. for cnum in sess.cstore.crates() { - let syms = sess.cstore.reachable_ids(cnum); - reachable_symbols.extend(syms.into_iter().filter(|&def_id| { + let syms = sess.cstore.exported_symbols(cnum); + exported_symbols.extend(syms.into_iter().filter(|&def_id| { let applicable = match sess.cstore.describe_def(def_id) { Some(Def::Static(..)) => true, Some(Def::Fn(_)) => { @@ -1735,7 +1735,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, internalize_symbols(sess, &crate_context_list, &symbol_map, - &reachable_symbols.iter() + &exported_symbols.iter() .map(|s| &s[..]) .collect()) }); @@ -1749,7 +1749,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, create_imps(&crate_context_list); } - let linker_info = LinkerInfo::new(&shared_ccx, &reachable_symbols); + let linker_info = LinkerInfo::new(&shared_ccx, &exported_symbols); let subsystem = attr::first_attr_value_str_by_name(&krate.attrs, "windows_subsystem"); @@ -1767,7 +1767,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, metadata_module: metadata_module, link: link_meta, metadata: metadata, - reachable: reachable_symbols, + exported_symbols: exported_symbols, no_builtins: no_builtins, linker_info: linker_info, windows_subsystem: windows_subsystem, diff --git a/src/librustc_trans/context.rs b/src/librustc_trans/context.rs index c0d7c64bd192c..262b83623977c 100644 --- a/src/librustc_trans/context.rs +++ b/src/librustc_trans/context.rs @@ -67,7 +67,7 @@ pub struct SharedCrateContext<'a, 'tcx: 'a> { metadata_llcx: ContextRef, export_map: ExportMap, - reachable: NodeSet, + exported_symbols: NodeSet, link_meta: LinkMeta, tcx: TyCtxt<'a, 'tcx, 'tcx>, stats: Stats, @@ -437,7 +437,7 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> { pub fn new(tcx: TyCtxt<'b, 'tcx, 'tcx>, export_map: ExportMap, link_meta: LinkMeta, - reachable: NodeSet, + exported_symbols: NodeSet, check_overflow: bool) -> SharedCrateContext<'b, 'tcx> { let (metadata_llcx, metadata_llmod) = unsafe { @@ -454,7 +454,7 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> { // they're not available to be linked against. This poses a few problems // for the compiler, some of which are somewhat fundamental, but we use // the `use_dll_storage_attrs` variable below to attach the `dllexport` - // attribute to all LLVM functions that are reachable (e.g. they're + // attribute to all LLVM functions that are exported e.g. they're // already tagged with external linkage). This is suboptimal for a few // reasons: // @@ -493,7 +493,7 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> { metadata_llmod: metadata_llmod, metadata_llcx: metadata_llcx, export_map: export_map, - reachable: reachable, + exported_symbols: exported_symbols, link_meta: link_meta, tcx: tcx, stats: Stats { @@ -527,8 +527,8 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> { &self.export_map } - pub fn reachable<'a>(&'a self) -> &'a NodeSet { - &self.reachable + pub fn exported_symbols<'a>(&'a self) -> &'a NodeSet { + &self.exported_symbols } pub fn trait_cache(&self) -> &RefCell>> { @@ -768,8 +768,8 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> { &self.shared.export_map } - pub fn reachable<'a>(&'a self) -> &'a NodeSet { - &self.shared.reachable + pub fn exported_symbols<'a>(&'a self) -> &'a NodeSet { + &self.shared.exported_symbols } pub fn link_meta<'a>(&'a self) -> &'a LinkMeta { diff --git a/src/librustc_trans/debuginfo/utils.rs b/src/librustc_trans/debuginfo/utils.rs index 7cac9172a9c8b..3ee2497009f65 100644 --- a/src/librustc_trans/debuginfo/utils.rs +++ b/src/librustc_trans/debuginfo/utils.rs @@ -34,7 +34,7 @@ pub fn is_node_local_to_unit(cx: &CrateContext, node_id: ast::NodeId) -> bool // visible). It might better to use the `exported_items` set from // `driver::CrateAnalysis` in the future, but (atm) this set is not // available in the translation pass. - !cx.reachable().contains(&node_id) + !cx.exported_symbols().contains(&node_id) } #[allow(non_snake_case)] diff --git a/src/librustc_trans/lib.rs b/src/librustc_trans/lib.rs index 0e7ead30a933a..8a7ab16ee2b01 100644 --- a/src/librustc_trans/lib.rs +++ b/src/librustc_trans/lib.rs @@ -169,7 +169,7 @@ pub struct CrateTranslation { pub metadata_module: ModuleTranslation, pub link: middle::cstore::LinkMeta, pub metadata: Vec, - pub reachable: Vec, + pub exported_symbols: Vec, pub no_builtins: bool, pub windows_subsystem: Option, pub linker_info: back::linker::LinkerInfo