Skip to content

Commit 5fd7c2b

Browse files
trans: Rename reachable to exported_symbols where appropriate.
1 parent d1a6d47 commit 5fd7c2b

File tree

12 files changed

+62
-62
lines changed

12 files changed

+62
-62
lines changed

src/librustc/middle/cstore.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ pub trait CrateStore<'tcx> {
329329
fn crate_disambiguator(&self, cnum: CrateNum) -> Symbol;
330330
fn plugin_registrar_fn(&self, cnum: CrateNum) -> Option<DefId>;
331331
fn native_libraries(&self, cnum: CrateNum) -> Vec<NativeLibrary>;
332-
fn reachable_ids(&self, cnum: CrateNum) -> Vec<DefId>;
332+
fn exported_symbols(&self, cnum: CrateNum) -> Vec<DefId>;
333333
fn is_no_builtins(&self, cnum: CrateNum) -> bool;
334334

335335
// resolve
@@ -493,7 +493,7 @@ impl<'tcx> CrateStore<'tcx> for DummyCrateStore {
493493
{ bug!("plugin_registrar_fn") }
494494
fn native_libraries(&self, cnum: CrateNum) -> Vec<NativeLibrary>
495495
{ bug!("native_libraries") }
496-
fn reachable_ids(&self, cnum: CrateNum) -> Vec<DefId> { bug!("reachable_ids") }
496+
fn exported_symbols(&self, cnum: CrateNum) -> Vec<DefId> { bug!("exported_symbols") }
497497
fn is_no_builtins(&self, cnum: CrateNum) -> bool { bug!("is_no_builtins") }
498498

499499
// resolve

src/librustc_metadata/cstore_impl.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,9 @@ impl<'tcx> CrateStore<'tcx> for cstore::CStore {
311311
self.get_crate_data(cnum).get_native_libraries()
312312
}
313313

314-
fn reachable_ids(&self, cnum: CrateNum) -> Vec<DefId>
314+
fn exported_symbols(&self, cnum: CrateNum) -> Vec<DefId>
315315
{
316-
self.get_crate_data(cnum).get_reachable_ids()
316+
self.get_crate_data(cnum).get_exported_symbols()
317317
}
318318

319319
fn is_no_builtins(&self, cnum: CrateNum) -> bool {

src/librustc_metadata/decoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,8 +1038,8 @@ impl<'a, 'tcx> CrateMetadata {
10381038
arg_names.decode(self).collect()
10391039
}
10401040

1041-
pub fn get_reachable_ids(&self) -> Vec<DefId> {
1042-
self.root.reachable_ids.decode(self).map(|index| self.local_def_id(index)).collect()
1041+
pub fn get_exported_symbols(&self) -> Vec<DefId> {
1042+
self.root.exported_symbols.decode(self).map(|index| self.local_def_id(index)).collect()
10431043
}
10441044

10451045
pub fn get_macro(&self, id: DefIndex) -> (ast::Name, MacroDef) {

src/librustc_metadata/encoder.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub struct EncodeContext<'a, 'tcx: 'a> {
5050
reexports: &'a def::ExportMap,
5151
link_meta: &'a LinkMeta,
5252
cstore: &'a cstore::CStore,
53-
reachable: &'a NodeSet,
53+
exported_symbols: &'a NodeSet,
5454

5555
lazy_state: LazyState,
5656
type_shorthands: FxHashMap<Ty<'tcx>, usize>,
@@ -1223,16 +1223,16 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
12231223
self.lazy_seq(all_impls)
12241224
}
12251225

1226-
// Encodes all reachable symbols in this crate into the metadata.
1226+
// Encodes all symbols exported from this crate into the metadata.
12271227
//
12281228
// This pass is seeded off the reachability list calculated in the
12291229
// middle::reachable module but filters out items that either don't have a
12301230
// symbol associated with them (they weren't translated) or if they're an FFI
12311231
// definition (as that's not defined in this crate).
1232-
fn encode_reachable(&mut self) -> LazySeq<DefIndex> {
1233-
let reachable = self.reachable;
1232+
fn encode_exported_symbols(&mut self) -> LazySeq<DefIndex> {
1233+
let exported_symbols = self.exported_symbols;
12341234
let tcx = self.tcx;
1235-
self.lazy_seq(reachable.iter().map(|&id| tcx.map.local_def_id(id).index))
1235+
self.lazy_seq(exported_symbols.iter().map(|&id| tcx.map.local_def_id(id).index))
12361236
}
12371237

12381238
fn encode_dylib_dependency_formats(&mut self) -> LazySeq<Option<LinkagePreference>> {
@@ -1278,10 +1278,10 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
12781278
let impls = self.encode_impls();
12791279
let impl_bytes = self.position() - i;
12801280

1281-
// Encode reachability info.
1281+
// Encode exported symbols info.
12821282
i = self.position();
1283-
let reachable_ids = self.encode_reachable();
1284-
let reachable_bytes = self.position() - i;
1283+
let exported_symbols = self.encode_exported_symbols();
1284+
let exported_symbols_bytes = self.position() - i;
12851285

12861286
// Encode and index the items.
12871287
i = self.position();
@@ -1319,7 +1319,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
13191319
native_libraries: native_libraries,
13201320
codemap: codemap,
13211321
impls: impls,
1322-
reachable_ids: reachable_ids,
1322+
exported_symbols: exported_symbols,
13231323
index: index,
13241324
});
13251325

@@ -1339,7 +1339,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
13391339
println!(" native bytes: {}", native_lib_bytes);
13401340
println!(" codemap bytes: {}", codemap_bytes);
13411341
println!(" impl bytes: {}", impl_bytes);
1342-
println!(" reachable bytes: {}", reachable_bytes);
1342+
println!(" exp. symbols bytes: {}", exported_symbols_bytes);
13431343
println!(" item bytes: {}", item_bytes);
13441344
println!(" index bytes: {}", index_bytes);
13451345
println!(" zero bytes: {}", zero_bytes);
@@ -1377,7 +1377,7 @@ pub fn encode_metadata<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
13771377
cstore: &cstore::CStore,
13781378
reexports: &def::ExportMap,
13791379
link_meta: &LinkMeta,
1380-
reachable: &NodeSet)
1380+
exported_symbols: &NodeSet)
13811381
-> Vec<u8> {
13821382
let mut cursor = Cursor::new(vec![]);
13831383
cursor.write_all(METADATA_HEADER).unwrap();
@@ -1392,7 +1392,7 @@ pub fn encode_metadata<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
13921392
reexports: reexports,
13931393
link_meta: link_meta,
13941394
cstore: cstore,
1395-
reachable: reachable,
1395+
exported_symbols: exported_symbols,
13961396
lazy_state: LazyState::NoNode,
13971397
type_shorthands: Default::default(),
13981398
predicate_shorthands: Default::default(),

src/librustc_metadata/schema.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ pub struct CrateRoot {
180180
pub native_libraries: LazySeq<NativeLibrary>,
181181
pub codemap: LazySeq<syntax_pos::FileMap>,
182182
pub impls: LazySeq<TraitImpls>,
183-
pub reachable_ids: LazySeq<DefIndex>,
183+
pub exported_symbols: LazySeq<DefIndex>,
184184
pub index: LazySeq<index::Index>,
185185
}
186186

src/librustc_trans/back/linker.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ pub struct LinkerInfo {
3434

3535
impl<'a, 'tcx> LinkerInfo {
3636
pub fn new(scx: &SharedCrateContext<'a, 'tcx>,
37-
reachable: &[String]) -> LinkerInfo {
37+
exports: &[String]) -> LinkerInfo {
3838
LinkerInfo {
3939
exports: scx.sess().crate_types.borrow().iter().map(|&c| {
40-
(c, exported_symbols(scx, reachable, c))
40+
(c, exported_symbols(scx, exports, c))
4141
}).collect(),
4242
}
4343
}
@@ -473,7 +473,7 @@ impl<'a> Linker for MsvcLinker<'a> {
473473
}
474474

475475
fn exported_symbols(scx: &SharedCrateContext,
476-
reachable: &[String],
476+
exported_symbols: &[String],
477477
crate_type: CrateType)
478478
-> Vec<String> {
479479
// See explanation in GnuLinker::export_symbols, for
@@ -485,7 +485,7 @@ fn exported_symbols(scx: &SharedCrateContext,
485485
}
486486
}
487487

488-
let mut symbols = reachable.to_vec();
488+
let mut symbols = exported_symbols.to_vec();
489489

490490
// If we're producing anything other than a dylib then the `reachable` array
491491
// above is the exhaustive set of symbols we should be exporting.
@@ -507,7 +507,7 @@ fn exported_symbols(scx: &SharedCrateContext,
507507
None
508508
}
509509
}).flat_map(|cnum| {
510-
cstore.reachable_ids(cnum)
510+
cstore.exported_symbols(cnum)
511511
}).map(|did| -> String {
512512
Instance::mono(scx, did).symbol_name(scx)
513513
}));

src/librustc_trans/back/lto.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use std::ffi::CString;
2525
use std::path::Path;
2626

2727
pub fn run(sess: &session::Session, llmod: ModuleRef,
28-
tm: TargetMachineRef, reachable: &[String],
28+
tm: TargetMachineRef, exported_symbols: &[String],
2929
config: &ModuleConfig,
3030
temp_no_opt_bc_filename: &Path) {
3131
if sess.opts.cg.prefer_dynamic {
@@ -118,8 +118,8 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
118118
}
119119
});
120120

121-
// Internalize everything but the reachable symbols of the current module
122-
let cstrs: Vec<CString> = reachable.iter().map(|s| {
121+
// Internalize everything but the exported symbols of the current module
122+
let cstrs: Vec<CString> = exported_symbols.iter().map(|s| {
123123
CString::new(s.clone()).unwrap()
124124
}).collect();
125125
let arr: Vec<*const libc::c_char> = cstrs.iter().map(|c| c.as_ptr()).collect();

src/librustc_trans/back/write.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -343,9 +343,9 @@ struct CodegenContext<'a> {
343343
}
344344

345345
impl<'a> CodegenContext<'a> {
346-
fn new_with_session(sess: &'a Session, reachable: &'a [String]) -> CodegenContext<'a> {
346+
fn new_with_session(sess: &'a Session, exported_symbols: &'a [String]) -> CodegenContext<'a> {
347347
CodegenContext {
348-
lto_ctxt: Some((sess, reachable)),
348+
lto_ctxt: Some((sess, exported_symbols)),
349349
handler: sess.diagnostic(),
350350
plugin_passes: sess.plugin_llvm_passes.borrow().clone(),
351351
remark: sess.opts.cg.remark.clone(),
@@ -516,14 +516,14 @@ unsafe fn optimize_and_codegen(cgcx: &CodegenContext,
516516
llvm::LLVMDisposePassManager(mpm);
517517

518518
match cgcx.lto_ctxt {
519-
Some((sess, reachable)) if sess.lto() => {
519+
Some((sess, exported_symbols)) if sess.lto() => {
520520
time(sess.time_passes(), "all lto passes", || {
521521
let temp_no_opt_bc_filename =
522522
output_names.temp_path_ext("no-opt.lto.bc", module_name);
523523
lto::run(sess,
524524
llmod,
525525
tm,
526-
reachable,
526+
exported_symbols,
527527
&config,
528528
&temp_no_opt_bc_filename);
529529
});
@@ -753,7 +753,7 @@ pub fn run_passes(sess: &Session,
753753
// potentially create hundreds of them).
754754
let num_workers = work_items.len() - 1;
755755
if num_workers == 1 {
756-
run_work_singlethreaded(sess, &trans.reachable, work_items);
756+
run_work_singlethreaded(sess, &trans.exported_symbols, work_items);
757757
} else {
758758
run_work_multithreaded(sess, work_items, num_workers);
759759
}
@@ -997,9 +997,9 @@ fn execute_work_item(cgcx: &CodegenContext,
997997
}
998998

999999
fn run_work_singlethreaded(sess: &Session,
1000-
reachable: &[String],
1000+
exported_symbols: &[String],
10011001
work_items: Vec<WorkItem>) {
1002-
let cgcx = CodegenContext::new_with_session(sess, reachable);
1002+
let cgcx = CodegenContext::new_with_session(sess, exported_symbols);
10031003

10041004
// Since we're running single-threaded, we can pass the session to
10051005
// the proc, allowing `optimize_and_codegen` to perform LTO.

src/librustc_trans/base.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,7 +1243,7 @@ fn contains_null(s: &str) -> bool {
12431243
}
12441244

12451245
fn write_metadata(cx: &SharedCrateContext,
1246-
reachable_ids: &NodeSet) -> Vec<u8> {
1246+
exported_symbols: &NodeSet) -> Vec<u8> {
12471247
use flate;
12481248

12491249
#[derive(PartialEq, Eq, PartialOrd, Ord)]
@@ -1275,7 +1275,7 @@ fn write_metadata(cx: &SharedCrateContext,
12751275
let metadata = cstore.encode_metadata(cx.tcx(),
12761276
cx.export_map(),
12771277
cx.link_meta(),
1278-
reachable_ids);
1278+
exported_symbols);
12791279
if kind == MetadataKind::Uncompressed {
12801280
return metadata;
12811281
}
@@ -1313,7 +1313,7 @@ fn write_metadata(cx: &SharedCrateContext,
13131313
fn internalize_symbols<'a, 'tcx>(sess: &Session,
13141314
ccxs: &CrateContextList<'a, 'tcx>,
13151315
symbol_map: &SymbolMap<'tcx>,
1316-
reachable: &FxHashSet<&str>) {
1316+
exported_symbols: &FxHashSet<&str>) {
13171317
let scx = ccxs.shared();
13181318
let tcx = scx.tcx();
13191319

@@ -1379,7 +1379,7 @@ fn internalize_symbols<'a, 'tcx>(sess: &Session,
13791379
let name_cow = Cow::Borrowed(name_str);
13801380

13811381
let is_referenced_somewhere = referenced_somewhere.contains(&name_cstr);
1382-
let is_reachable = reachable.contains(&name_str);
1382+
let is_reachable = exported_symbols.contains(&name_str);
13831383
let has_fixed_linkage = linkage_fixed_explicitly.contains(&name_cow);
13841384

13851385
if !is_referenced_somewhere && !is_reachable && !has_fixed_linkage {
@@ -1481,7 +1481,7 @@ fn iter_functions(llmod: llvm::ModuleRef) -> ValueIter {
14811481
///
14821482
/// This list is later used by linkers to determine the set of symbols needed to
14831483
/// be exposed from a dynamic library and it's also encoded into the metadata.
1484-
pub fn filter_reachable_ids(tcx: TyCtxt, reachable: NodeSet) -> NodeSet {
1484+
pub fn find_exported_symbols(tcx: TyCtxt, reachable: NodeSet) -> NodeSet {
14851485
reachable.into_iter().filter(|&id| {
14861486
// Next, we want to ignore some FFI functions that are not exposed from
14871487
// 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>,
15351535
let krate = tcx.map.krate();
15361536

15371537
let ty::CrateAnalysis { export_map, reachable, name, .. } = analysis;
1538-
let reachable = filter_reachable_ids(tcx, reachable);
1538+
let exported_symbols = find_exported_symbols(tcx, reachable);
15391539

15401540
let check_overflow = if let Some(v) = tcx.sess.opts.debugging_opts.force_overflow_checks {
15411541
v
@@ -1548,11 +1548,11 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
15481548
let shared_ccx = SharedCrateContext::new(tcx,
15491549
export_map,
15501550
link_meta.clone(),
1551-
reachable,
1551+
exported_symbols,
15521552
check_overflow);
15531553
// Translate the metadata.
15541554
let metadata = time(tcx.sess.time_passes(), "write metadata", || {
1555-
write_metadata(&shared_ccx, shared_ccx.reachable())
1555+
write_metadata(&shared_ccx, shared_ccx.exported_symbols())
15561556
});
15571557

15581558
let metadata_module = ModuleTranslation {
@@ -1608,7 +1608,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
16081608
metadata_module: metadata_module,
16091609
link: link_meta,
16101610
metadata: metadata,
1611-
reachable: vec![],
1611+
exported_symbols: vec![],
16121612
no_builtins: no_builtins,
16131613
linker_info: linker_info,
16141614
windows_subsystem: None,
@@ -1688,17 +1688,17 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
16881688
}
16891689

16901690
let sess = shared_ccx.sess();
1691-
let mut reachable_symbols = shared_ccx.reachable().iter().map(|&id| {
1691+
let mut exported_symbols = shared_ccx.exported_symbols().iter().map(|&id| {
16921692
let def_id = shared_ccx.tcx().map.local_def_id(id);
16931693
symbol_for_def_id(def_id, &shared_ccx, &symbol_map)
16941694
}).collect::<Vec<_>>();
16951695

16961696
if sess.entry_fn.borrow().is_some() {
1697-
reachable_symbols.push("main".to_string());
1697+
exported_symbols.push("main".to_string());
16981698
}
16991699

17001700
if sess.crate_types.borrow().contains(&config::CrateTypeDylib) {
1701-
reachable_symbols.push(shared_ccx.metadata_symbol_name());
1701+
exported_symbols.push(shared_ccx.metadata_symbol_name());
17021702
}
17031703

17041704
// 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>,
17081708
//
17091709
// Note that this happens even if LTO isn't requested or we're not creating
17101710
// a cdylib. In those cases, though, we're not even reading the
1711-
// `reachable_symbols` list later on so it should be ok.
1711+
// `exported_symbols` list later on so it should be ok.
17121712
for cnum in sess.cstore.crates() {
1713-
let syms = sess.cstore.reachable_ids(cnum);
1714-
reachable_symbols.extend(syms.into_iter().filter(|&def_id| {
1713+
let syms = sess.cstore.exported_symbols(cnum);
1714+
exported_symbols.extend(syms.into_iter().filter(|&def_id| {
17151715
let applicable = match sess.cstore.describe_def(def_id) {
17161716
Some(Def::Static(..)) => true,
17171717
Some(Def::Fn(_)) => {
@@ -1735,7 +1735,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
17351735
internalize_symbols(sess,
17361736
&crate_context_list,
17371737
&symbol_map,
1738-
&reachable_symbols.iter()
1738+
&exported_symbols.iter()
17391739
.map(|s| &s[..])
17401740
.collect())
17411741
});
@@ -1749,7 +1749,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
17491749
create_imps(&crate_context_list);
17501750
}
17511751

1752-
let linker_info = LinkerInfo::new(&shared_ccx, &reachable_symbols);
1752+
let linker_info = LinkerInfo::new(&shared_ccx, &exported_symbols);
17531753

17541754
let subsystem = attr::first_attr_value_str_by_name(&krate.attrs,
17551755
"windows_subsystem");
@@ -1767,7 +1767,7 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
17671767
metadata_module: metadata_module,
17681768
link: link_meta,
17691769
metadata: metadata,
1770-
reachable: reachable_symbols,
1770+
exported_symbols: exported_symbols,
17711771
no_builtins: no_builtins,
17721772
linker_info: linker_info,
17731773
windows_subsystem: windows_subsystem,

0 commit comments

Comments
 (0)