Auto merge of #32156 - pnkfelix:borrowck-on-mir-move-analysis, r=nikomatsakis
Move analysis for MIR borrowck This PR adds code for doing MIR-based gathering of the moves in a `fn` and the dataflow to determine where uninitialized locations flow to, analogous to how the same thing is done in `borrowck`. It also adds a couple attributes to print out graphviz visualizations of the analyzed MIR that includes the dataflow analysis results. cc @nikomatsakis
This commit is contained in:
commit
e3f2dfdece
34 changed files with 2014 additions and 136 deletions
|
|
@ -880,7 +880,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
|
|||
|
||||
time(time_passes,
|
||||
"borrow checking",
|
||||
|| borrowck::check_crate(tcx));
|
||||
|| borrowck::check_crate(tcx, &mir_map));
|
||||
|
||||
// Avoid overwhelming user with errors if type checking failed.
|
||||
// I'm not sure how helpful this is, to be honest, but it avoids
|
||||
|
|
|
|||
|
|
@ -56,6 +56,8 @@ use rustc_front::hir;
|
|||
use rustc_front::lowering::{lower_crate, LoweringContext};
|
||||
use rustc_front::print::pprust as pprust_hir;
|
||||
|
||||
use rustc::mir::mir_map::MirMap;
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Debug)]
|
||||
pub enum PpSourceMode {
|
||||
PpmNormal,
|
||||
|
|
@ -875,9 +877,10 @@ pub fn pretty_print_input(sess: Session,
|
|||
&arenas,
|
||||
&id,
|
||||
resolve::MakeGlobMap::No,
|
||||
|tcx, _, _, _| {
|
||||
|tcx, mir_map, _, _| {
|
||||
print_flowgraph(variants,
|
||||
tcx,
|
||||
mir_map.as_ref(),
|
||||
code,
|
||||
mode,
|
||||
out)
|
||||
|
|
@ -911,12 +914,13 @@ pub fn pretty_print_input(sess: Session,
|
|||
}
|
||||
}
|
||||
|
||||
fn print_flowgraph<W: Write>(variants: Vec<borrowck_dot::Variant>,
|
||||
tcx: &TyCtxt,
|
||||
code: blocks::Code,
|
||||
mode: PpFlowGraphMode,
|
||||
mut out: W)
|
||||
-> io::Result<()> {
|
||||
fn print_flowgraph<'tcx, W: Write>(variants: Vec<borrowck_dot::Variant>,
|
||||
tcx: &TyCtxt<'tcx>,
|
||||
mir_map: Option<&MirMap<'tcx>>,
|
||||
code: blocks::Code,
|
||||
mode: PpFlowGraphMode,
|
||||
mut out: W)
|
||||
-> io::Result<()> {
|
||||
let cfg = match code {
|
||||
blocks::BlockCode(block) => cfg::CFG::new(tcx, &block),
|
||||
blocks::FnLikeCode(fn_like) => cfg::CFG::new(tcx, &fn_like.body()),
|
||||
|
|
@ -942,6 +946,7 @@ fn print_flowgraph<W: Write>(variants: Vec<borrowck_dot::Variant>,
|
|||
blocks::FnLikeCode(fn_like) => {
|
||||
let (bccx, analysis_data) =
|
||||
borrowck::build_borrowck_dataflow_data_for_fn(tcx,
|
||||
mir_map,
|
||||
fn_like.to_fn_parts(),
|
||||
&cfg);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue