retool MIR passes completely

The new setup is as follows. There is a pipeline of MIR passes that each
run **per def-id** to optimize a particular function. You are intended
to request MIR at whatever stage you need it. At the moment, there is
only one stage you can request:

- `optimized_mir(def_id)`

This yields the final product. Internally, it pulls the MIR for the
given def-id through a series of steps. Right now, these are still using
an "interned ref-cell" but they are intended to "steal" from one
another:

- `mir_build` -- performs the initial construction for local MIR
- `mir_pass_set` -- performs a suite of optimizations and transformations
- `mir_pass` -- an individual optimization within a suite

So, to construct the optimized MIR, we invoke:

    mir_pass_set((MIR_OPTIMIZED, def_id))

which will build up the final MIR.
This commit is contained in:
Niko Matsakis 2017-04-27 16:48:48 -04:00
parent f23a7bc98a
commit 2b32cb90c7
13 changed files with 344 additions and 184 deletions

View file

@ -1005,11 +1005,6 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
mir_stats::print_mir_stats(tcx, "PRE CLEANUP MIR STATS");
}
time(time_passes, "MIR cleanup and validation", || {
tcx.mir_passes.run_passes(tcx, MIR_CONST);
tcx.mir_passes.run_passes(tcx, MIR_VALIDATED);
});
time(time_passes,
"borrow checking",
|| borrowck::check_crate(tcx));
@ -1058,20 +1053,6 @@ pub fn phase_4_translate_to_llvm<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
"resolving dependency formats",
|| dependency_format::calculate(&tcx.sess));
if tcx.sess.opts.debugging_opts.mir_stats {
mir_stats::print_mir_stats(tcx, "PRE OPTIMISATION MIR STATS");
}
// Run the passes that transform the MIR into a more suitable form for translation to LLVM
// code.
time(time_passes, "MIR optimisations", || {
tcx.mir_passes.run_passes(tcx, MIR_OPTIMIZED);
});
if tcx.sess.opts.debugging_opts.mir_stats {
mir_stats::print_mir_stats(tcx, "POST OPTIMISATION MIR STATS");
}
let translation =
time(time_passes,
"translation",