Skip to content

Commit baca9a6

Browse files
committed
rustc: Use reachablility through a query
Turns out this was already set up as a query, just wasn't using it yet!
1 parent a97ad6a commit baca9a6

File tree

4 files changed

+5
-20
lines changed

4 files changed

+5
-20
lines changed

src/librustc/middle/reachable.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,6 @@ impl<'a, 'tcx: 'a> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a,
369369
}
370370
}
371371

372-
pub fn find_reachable<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Rc<NodeSet> {
373-
tcx.reachable_set(LOCAL_CRATE)
374-
}
375-
376372
fn reachable_set<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum) -> Rc<NodeSet> {
377373
debug_assert!(crate_num == LOCAL_CRATE);
378374

src/librustc/ty/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@ mod sty;
121121
#[derive(Clone)]
122122
pub struct CrateAnalysis {
123123
pub access_levels: Rc<AccessLevels>,
124-
pub reachable: Rc<NodeSet>,
125124
pub name: String,
126125
pub glob_map: Option<hir::GlobMap>,
127126
}

src/librustc_driver/driver.rs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ use rustc::mir::transform::{MIR_CONST, MIR_VALIDATED, MIR_OPTIMIZED, Passes};
2828
use rustc::ty::{self, TyCtxt, Resolutions, GlobalArenas};
2929
use rustc::traits;
3030
use rustc::util::common::{ErrorReported, time};
31-
use rustc::util::nodemap::NodeSet;
3231
use rustc_allocator as allocator;
3332
use rustc_borrowck as borrowck;
3433
use rustc_incremental::{self, IncrementalHashesMap};
@@ -243,7 +242,7 @@ pub fn compile_input(sess: &Session,
243242
tcx.print_debug_stats();
244243
}
245244

246-
let trans = phase_4_translate_to_llvm(tcx, analysis, incremental_hashes_map,
245+
let trans = phase_4_translate_to_llvm(tcx, incremental_hashes_map,
247246
&outputs);
248247

249248
if log_enabled!(::log::LogLevel::Info) {
@@ -885,7 +884,6 @@ pub fn phase_2_configure_and_expand<F>(sess: &Session,
885884
defs: resolver.definitions,
886885
analysis: ty::CrateAnalysis {
887886
access_levels: Rc::new(AccessLevels::default()),
888-
reachable: Rc::new(NodeSet()),
889887
name: crate_name.to_string(),
890888
glob_map: if resolver.make_glob_map { Some(resolver.glob_map) } else { None },
891889
},
@@ -1103,11 +1101,6 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
11031101
return Ok(f(tcx, analysis, incremental_hashes_map, sess.compile_status()));
11041102
}
11051103

1106-
analysis.reachable =
1107-
time(time_passes,
1108-
"reachability checking",
1109-
|| reachable::find_reachable(tcx));
1110-
11111104
time(time_passes, "death checking", || middle::dead::check_crate(tcx));
11121105

11131106
time(time_passes, "unused lib feature checking", || {
@@ -1123,7 +1116,6 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
11231116
/// Run the translation phase to LLVM, after which the AST and analysis can
11241117
/// be discarded.
11251118
pub fn phase_4_translate_to_llvm<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
1126-
analysis: ty::CrateAnalysis,
11271119
incremental_hashes_map: IncrementalHashesMap,
11281120
output_filenames: &OutputFilenames)
11291121
-> write::OngoingCrateTranslation {
@@ -1136,7 +1128,7 @@ pub fn phase_4_translate_to_llvm<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
11361128
let translation =
11371129
time(time_passes,
11381130
"translation",
1139-
move || trans::trans_crate(tcx, analysis, incremental_hashes_map, output_filenames));
1131+
move || trans::trans_crate(tcx, incremental_hashes_map, output_filenames));
11401132

11411133
if tcx.sess.profile_queries() {
11421134
profile::dump("profile_queries".to_string())

src/librustc_trans/base.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -886,8 +886,8 @@ fn iter_globals(llmod: llvm::ModuleRef) -> ValueIter {
886886
///
887887
/// This list is later used by linkers to determine the set of symbols needed to
888888
/// be exposed from a dynamic library and it's also encoded into the metadata.
889-
pub fn find_exported_symbols(tcx: TyCtxt, reachable: &NodeSet) -> NodeSet {
890-
reachable.iter().cloned().filter(|&id| {
889+
pub fn find_exported_symbols(tcx: TyCtxt) -> NodeSet {
890+
tcx.reachable_set(LOCAL_CRATE).iter().cloned().filter(|&id| {
891891
// Next, we want to ignore some FFI functions that are not exposed from
892892
// this crate. Reachable FFI functions can be lumped into two
893893
// categories:
@@ -929,7 +929,6 @@ pub fn find_exported_symbols(tcx: TyCtxt, reachable: &NodeSet) -> NodeSet {
929929
}
930930

931931
pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
932-
analysis: ty::CrateAnalysis,
933932
incremental_hashes_map: IncrementalHashesMap,
934933
output_filenames: &OutputFilenames)
935934
-> OngoingCrateTranslation {
@@ -940,10 +939,9 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
940939
// `TransCrate`, you need to be careful to register "reads" of the
941940
// particular items that will be processed.
942941
let krate = tcx.hir.krate();
943-
let ty::CrateAnalysis { reachable, .. } = analysis;
944942
let check_overflow = tcx.sess.overflow_checks();
945943
let link_meta = link::build_link_meta(&incremental_hashes_map);
946-
let exported_symbol_node_ids = find_exported_symbols(tcx, &reachable);
944+
let exported_symbol_node_ids = find_exported_symbols(tcx);
947945

948946
let shared_ccx = SharedCrateContext::new(tcx,
949947
check_overflow,

0 commit comments

Comments
 (0)