提交 3c07b461 编写于 作者: N Niko Matsakis

Pass the mir map to trans

上级 15c1da4e
......@@ -103,7 +103,7 @@ DEPS_rustc_mir := rustc rustc_front syntax
DEPS_rustc_resolve := rustc rustc_front log syntax
DEPS_rustc_platform_intrinsics := rustc rustc_llvm
DEPS_rustc_privacy := rustc rustc_front log syntax
DEPS_rustc_trans := arena flate getopts graphviz libc rustc rustc_back \
DEPS_rustc_trans := arena flate getopts graphviz libc rustc rustc_back rustc_mir \
log syntax serialize rustc_llvm rustc_front rustc_platform_intrinsics
DEPS_rustc_typeck := rustc syntax rustc_front rustc_platform_intrinsics
......
......@@ -11,6 +11,7 @@
use rustc::front;
use rustc::front::map as hir_map;
use rustc_mir as mir;
use rustc_mir::mir_map::MirMap;
use rustc::session::Session;
use rustc::session::config::{self, Input, OutputFilenames, OutputType};
use rustc::session::search_paths::PathKind;
......@@ -22,6 +23,7 @@
use rustc::middle;
use rustc::plugin::registry::Registry;
use rustc::plugin;
use rustc::util::nodemap::NodeMap;
use rustc::util::common::time;
use rustc_borrowck as borrowck;
use rustc_resolve as resolve;
......@@ -146,7 +148,7 @@ pub fn compile_input(sess: Session,
&arenas,
&id,
control.make_glob_map,
|tcx, analysis| {
|tcx, mir_map, analysis| {
{
let state = CompileState::state_after_analysis(input,
......@@ -170,7 +172,7 @@ pub fn compile_input(sess: Session,
println!("Pre-trans");
tcx.print_debug_stats();
}
let trans = phase_4_translate_to_llvm(tcx, analysis);
let trans = phase_4_translate_to_llvm(tcx, &mir_map, analysis);
if log_enabled!(::log::INFO) {
println!("Post-trans");
......@@ -670,6 +672,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
f: F)
-> R
where F: for<'a> FnOnce(&'a ty::ctxt<'tcx>,
MirMap<'tcx>,
ty::CrateAnalysis) -> R
{
let time_passes = sess.time_passes();
......@@ -751,18 +754,18 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
time(time_passes, "match checking", ||
middle::check_match::check_crate(tcx));
match tcx.sess.opts.unstable_features {
let mir_map = match tcx.sess.opts.unstable_features {
UnstableFeatures::Disallow => {
// use this as a shorthand for beta/stable, and skip
// MIR construction there until known regressions are
// addressed
NodeMap()
}
UnstableFeatures::Allow | UnstableFeatures::Cheat => {
let _mir_map =
time(time_passes, "MIR dump", ||
mir::mir_map::build_mir_for_crate(tcx));
time(time_passes, "MIR dump", ||
mir::mir_map::build_mir_for_crate(tcx))
}
}
};
time(time_passes, "liveness checking", ||
middle::liveness::check_crate(tcx));
......@@ -804,7 +807,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
// The above three passes generate errors w/o aborting
tcx.sess.abort_if_errors();
f(tcx, ty::CrateAnalysis {
f(tcx, mir_map, ty::CrateAnalysis {
export_map: export_map,
exported_items: exported_items,
public_items: public_items,
......@@ -817,8 +820,10 @@ 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(tcx: &ty::ctxt, analysis: ty::CrateAnalysis)
-> trans::CrateTranslation {
pub fn phase_4_translate_to_llvm<'tcx>(tcx: &ty::ctxt<'tcx>,
mir_map: &MirMap<'tcx>,
analysis: ty::CrateAnalysis)
-> trans::CrateTranslation {
let time_passes = tcx.sess.time_passes();
time(time_passes, "resolving dependency formats", ||
......@@ -826,7 +831,7 @@ pub fn phase_4_translate_to_llvm(tcx: &ty::ctxt, analysis: ty::CrateAnalysis)
// Option dance to work around the lack of stack once closures.
time(time_passes, "translation", move ||
trans::trans_crate(tcx, analysis))
trans::trans_crate(tcx, mir_map, analysis))
}
/// Run LLVM itself, producing a bitcode file, assembly file or object file
......
......@@ -182,7 +182,7 @@ fn call_with_pp_support_hir<'tcx, A, B, F>(&self,
arenas,
id,
resolve::MakeGlobMap::No,
|tcx, _| {
|tcx, _, _| {
let annotation = TypedAnnotation { tcx: tcx };
f(&annotation, payload, &ast_map.forest.krate)
})
......@@ -782,7 +782,7 @@ pub fn pretty_print_input(sess: Session,
&arenas,
&id,
resolve::MakeGlobMap::No,
|tcx, _| {
|tcx, _, _| {
print_flowgraph(variants, tcx, code, mode, out)
})
}
......
......@@ -37,6 +37,7 @@
#![feature(quote)]
#![feature(rustc_diagnostic_macros)]
#![feature(rustc_private)]
#![feature(slice_patterns)]
#![feature(staged_api)]
#![feature(unicode)]
#![feature(vec_push_all)]
......@@ -52,6 +53,7 @@
extern crate rustc_back;
extern crate rustc_front;
extern crate rustc_llvm as llvm;
extern crate rustc_mir;
extern crate rustc_platform_intrinsics as intrinsics;
extern crate serialize;
......
......@@ -44,6 +44,7 @@
use middle::subst::Substs;
use middle::ty::{self, Ty, HasTypeFlags};
use rustc::front::map as hir_map;
use rustc_mir::mir_map::MirMap;
use session::config::{self, NoDebugInfo, FullDebugInfo};
use session::Session;
use trans::_match;
......@@ -2737,7 +2738,10 @@ pub fn filter_reachable_ids(ccx: &SharedCrateContext) -> NodeSet {
}).collect()
}
pub fn trans_crate(tcx: &ty::ctxt, analysis: ty::CrateAnalysis) -> CrateTranslation {
pub fn trans_crate<'tcx>(tcx: &ty::ctxt<'tcx>,
mir_map: &MirMap<'tcx>,
analysis: ty::CrateAnalysis)
-> CrateTranslation {
let ty::CrateAnalysis { export_map, reachable, name, .. } = analysis;
let krate = tcx.map.krate();
......@@ -2779,6 +2783,7 @@ pub fn trans_crate(tcx: &ty::ctxt, analysis: ty::CrateAnalysis) -> CrateTranslat
let shared_ccx = SharedCrateContext::new(&link_meta.crate_name,
codegen_units,
tcx,
&mir_map,
export_map,
Sha256::new(),
link_meta.clone(),
......
......@@ -14,6 +14,7 @@
use middle::def::ExportMap;
use middle::def_id::DefId;
use middle::traits;
use rustc_mir::mir_map::MirMap;
use trans::adt;
use trans::base;
use trans::builder::Builder;
......@@ -70,6 +71,7 @@ pub struct SharedCrateContext<'a, 'tcx: 'a> {
stats: Stats,
check_overflow: bool,
check_drop_flag_for_sanity: bool,
mir_map: &'a MirMap<'tcx>,
available_drop_glues: RefCell<FnvHashMap<DropGlueKind<'tcx>, String>>,
use_dll_storage_attrs: bool,
......@@ -251,6 +253,7 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> {
pub fn new(crate_name: &str,
local_count: usize,
tcx: &'b ty::ctxt<'tcx>,
mir_map: &'b MirMap<'tcx>,
export_map: ExportMap,
symbol_hasher: Sha256,
link_meta: LinkMeta,
......@@ -317,6 +320,7 @@ pub fn new(crate_name: &str,
link_meta: link_meta,
symbol_hasher: RefCell::new(symbol_hasher),
tcx: tcx,
mir_map: mir_map,
stats: Stats {
n_glues_created: Cell::new(0),
n_null_glues: Cell::new(0),
......@@ -803,6 +807,10 @@ pub fn check_drop_flag_for_sanity(&self) -> bool {
pub fn use_dll_storage_attrs(&self) -> bool {
self.shared.use_dll_storage_attrs()
}
pub fn mir_map(&self) -> &'b MirMap<'tcx> {
self.shared.mir_map
}
}
pub struct TypeOfDepthLock<'a, 'tcx: 'a>(&'a LocalCrateContext<'tcx>);
......
......@@ -145,7 +145,7 @@ pub fn run_core(search_paths: SearchPaths, cfgs: Vec<String>, externs: Externs,
&arenas,
&name,
resolve::MakeGlobMap::No,
|tcx, analysis| {
|tcx, _, analysis| {
let ty::CrateAnalysis { exported_items, public_items, .. } = analysis;
// Convert from a NodeId set to a DefId set since we don't always have easy access
......
......@@ -229,9 +229,9 @@ fn compile_program(input: &str, sysroot: PathBuf)
let ast_map = driver::make_map(&sess, &mut hir_forest);
driver::phase_3_run_analysis_passes(
&sess, ast_map, &arenas, &id, MakeGlobMap::No, |tcx, analysis| {
&sess, ast_map, &arenas, &id, MakeGlobMap::No, |tcx, mir_map, analysis| {
let trans = driver::phase_4_translate_to_llvm(tcx, analysis);
let trans = driver::phase_4_translate_to_llvm(tcx, &mir_map, analysis);
let crates = tcx.sess.cstore.get_used_crates(RequireDynamic);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册