rustc: Use reachablility through a query
Turns out this was already set up as a query, just wasn't using it yet!
This commit is contained in:
parent
a97ad6ae50
commit
baca9a6240
@ -369,10 +369,6 @@ impl<'a, 'tcx: 'a> ItemLikeVisitor<'tcx> for CollectPrivateImplItemsVisitor<'a,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn find_reachable<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>) -> Rc<NodeSet> {
|
||||
tcx.reachable_set(LOCAL_CRATE)
|
||||
}
|
||||
|
||||
fn reachable_set<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, crate_num: CrateNum) -> Rc<NodeSet> {
|
||||
debug_assert!(crate_num == LOCAL_CRATE);
|
||||
|
||||
|
@ -121,7 +121,6 @@ mod sty;
|
||||
#[derive(Clone)]
|
||||
pub struct CrateAnalysis {
|
||||
pub access_levels: Rc<AccessLevels>,
|
||||
pub reachable: Rc<NodeSet>,
|
||||
pub name: String,
|
||||
pub glob_map: Option<hir::GlobMap>,
|
||||
}
|
||||
|
@ -28,7 +28,6 @@ use rustc::mir::transform::{MIR_CONST, MIR_VALIDATED, MIR_OPTIMIZED, Passes};
|
||||
use rustc::ty::{self, TyCtxt, Resolutions, GlobalArenas};
|
||||
use rustc::traits;
|
||||
use rustc::util::common::{ErrorReported, time};
|
||||
use rustc::util::nodemap::NodeSet;
|
||||
use rustc_allocator as allocator;
|
||||
use rustc_borrowck as borrowck;
|
||||
use rustc_incremental::{self, IncrementalHashesMap};
|
||||
@ -243,7 +242,7 @@ pub fn compile_input(sess: &Session,
|
||||
tcx.print_debug_stats();
|
||||
}
|
||||
|
||||
let trans = phase_4_translate_to_llvm(tcx, analysis, incremental_hashes_map,
|
||||
let trans = phase_4_translate_to_llvm(tcx, incremental_hashes_map,
|
||||
&outputs);
|
||||
|
||||
if log_enabled!(::log::LogLevel::Info) {
|
||||
@ -885,7 +884,6 @@ pub fn phase_2_configure_and_expand<F>(sess: &Session,
|
||||
defs: resolver.definitions,
|
||||
analysis: ty::CrateAnalysis {
|
||||
access_levels: Rc::new(AccessLevels::default()),
|
||||
reachable: Rc::new(NodeSet()),
|
||||
name: crate_name.to_string(),
|
||||
glob_map: if resolver.make_glob_map { Some(resolver.glob_map) } else { None },
|
||||
},
|
||||
@ -1103,11 +1101,6 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
|
||||
return Ok(f(tcx, analysis, incremental_hashes_map, sess.compile_status()));
|
||||
}
|
||||
|
||||
analysis.reachable =
|
||||
time(time_passes,
|
||||
"reachability checking",
|
||||
|| reachable::find_reachable(tcx));
|
||||
|
||||
time(time_passes, "death checking", || middle::dead::check_crate(tcx));
|
||||
|
||||
time(time_passes, "unused lib feature checking", || {
|
||||
@ -1123,7 +1116,6 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
|
||||
/// Run the translation phase to LLVM, after which the AST and analysis can
|
||||
/// be discarded.
|
||||
pub fn phase_4_translate_to_llvm<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
analysis: ty::CrateAnalysis,
|
||||
incremental_hashes_map: IncrementalHashesMap,
|
||||
output_filenames: &OutputFilenames)
|
||||
-> write::OngoingCrateTranslation {
|
||||
@ -1136,7 +1128,7 @@ pub fn phase_4_translate_to_llvm<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
let translation =
|
||||
time(time_passes,
|
||||
"translation",
|
||||
move || trans::trans_crate(tcx, analysis, incremental_hashes_map, output_filenames));
|
||||
move || trans::trans_crate(tcx, incremental_hashes_map, output_filenames));
|
||||
|
||||
if tcx.sess.profile_queries() {
|
||||
profile::dump("profile_queries".to_string())
|
||||
|
@ -886,8 +886,8 @@ fn iter_globals(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 find_exported_symbols(tcx: TyCtxt, reachable: &NodeSet) -> NodeSet {
|
||||
reachable.iter().cloned().filter(|&id| {
|
||||
pub fn find_exported_symbols(tcx: TyCtxt) -> NodeSet {
|
||||
tcx.reachable_set(LOCAL_CRATE).iter().cloned().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
|
||||
// categories:
|
||||
@ -929,7 +929,6 @@ pub fn find_exported_symbols(tcx: TyCtxt, reachable: &NodeSet) -> NodeSet {
|
||||
}
|
||||
|
||||
pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
analysis: ty::CrateAnalysis,
|
||||
incremental_hashes_map: IncrementalHashesMap,
|
||||
output_filenames: &OutputFilenames)
|
||||
-> OngoingCrateTranslation {
|
||||
@ -940,10 +939,9 @@ pub fn trans_crate<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
// `TransCrate`, you need to be careful to register "reads" of the
|
||||
// particular items that will be processed.
|
||||
let krate = tcx.hir.krate();
|
||||
let ty::CrateAnalysis { reachable, .. } = analysis;
|
||||
let check_overflow = tcx.sess.overflow_checks();
|
||||
let link_meta = link::build_link_meta(&incremental_hashes_map);
|
||||
let exported_symbol_node_ids = find_exported_symbols(tcx, &reachable);
|
||||
let exported_symbol_node_ids = find_exported_symbols(tcx);
|
||||
|
||||
let shared_ccx = SharedCrateContext::new(tcx,
|
||||
check_overflow,
|
||||
|
Loading…
Reference in New Issue
Block a user