]> git.lizzy.rs Git - rust.git/commitdiff
remove `Pass` and (temporarily) drop `Inline`
authorNiko Matsakis <niko@alum.mit.edu>
Mon, 1 May 2017 16:47:00 +0000 (12:47 -0400)
committerNiko Matsakis <niko@alum.mit.edu>
Tue, 2 May 2017 20:21:55 +0000 (16:21 -0400)
src/librustc/mir/transform.rs
src/librustc_driver/driver.rs
src/librustc_mir/transform/inline.rs
src/librustc_mir/transform/mod.rs

index 69dc83f6dcc84e5eb0bb659713adb54e7b2ea908..28b34459b30f988422c7556d2aa6d47cccb7a28e 100644 (file)
@@ -15,8 +15,6 @@
 use hir::map::DefPathData;
 use mir::{Mir, Promoted};
 use ty::TyCtxt;
-use ty::maps::Multi;
-use ty::steal::Steal;
 use std::cell::Ref;
 use std::rc::Rc;
 use syntax::ast::NodeId;
@@ -135,19 +133,6 @@ fn on_mir_pass<'a, 'tcx: 'a>(&self,
 /// application of a pass to a def-id.
 pub type PassId = (MirSuite, MirPassIndex, DefId);
 
-/// The most generic sort of MIR pass. You only want to implement this
-/// rather general trait if you are doing an interprocedural pass that
-/// may inspect and affect the MIR of many def-ids. Otherwise, prefer
-/// the more steamlined `DefIdPass` or `MirPass`.
-pub trait Pass {
-    fn name<'a>(&'a self) -> Cow<'a, str> {
-        default_name::<Self>()
-    }
-
-    fn run_pass<'a, 'tcx: 'a>(&self, mir_cx: &MirCtxt<'a, 'tcx>)
-                              -> Multi<PassId, &'tcx Steal<Mir<'tcx>>>;
-}
-
 /// A streamlined trait that you can implement to create an
 /// intraprocedural pass; the pass will be invoked to process the MIR
 /// with the given `def_id`.  This lets you do things before we fetch
@@ -160,17 +145,6 @@ fn name<'a>(&'a self) -> Cow<'a, str> {
     fn run_pass<'a, 'tcx: 'a>(&self, mir_cx: &MirCtxt<'a, 'tcx>) -> Mir<'tcx>;
 }
 
-impl<T: DefIdPass> Pass for T {
-    fn name<'a>(&'a self) -> Cow<'a, str> {
-        DefIdPass::name(self)
-    }
-
-    fn run_pass<'a, 'tcx: 'a>(&self, mir_cx: &MirCtxt<'a, 'tcx>)
-                              -> Multi<PassId, &'tcx Steal<Mir<'tcx>>> {
-        Multi::from(mir_cx.tcx().alloc_steal_mir(DefIdPass::run_pass(self, mir_cx)))
-    }
-}
-
 /// A streamlined trait that you can implement to create a pass; the
 /// pass will be named after the type, and it will consist of a main
 /// loop that goes over each available MIR and applies `run_pass`.
@@ -210,7 +184,7 @@ fn run_pass<'a, 'tcx: 'a>(&self, mir_cx: &MirCtxt<'a, 'tcx>) -> Mir<'tcx> {
 #[derive(Clone)]
 pub struct Passes {
     pass_hooks: Vec<Rc<PassHook>>,
-    suites: Vec<Vec<Rc<Pass>>>,
+    suites: Vec<Vec<Rc<DefIdPass>>>,
 }
 
 /// The number of "pass suites" that we have:
@@ -238,7 +212,7 @@ pub fn new() -> Passes {
     }
 
     /// Pushes a built-in pass.
-    pub fn push_pass<T: Pass + 'static>(&mut self, suite: MirSuite, pass: T) {
+    pub fn push_pass<T: DefIdPass + 'static>(&mut self, suite: MirSuite, pass: T) {
         self.suites[suite.0].push(Rc::new(pass));
     }
 
@@ -251,7 +225,7 @@ pub fn len_passes(&self, suite: MirSuite) -> usize {
         self.suites[suite.0].len()
     }
 
-    pub fn pass(&self, suite: MirSuite, pass: MirPassIndex) -> &Pass {
+    pub fn pass(&self, suite: MirSuite, pass: MirPassIndex) -> &DefIdPass {
         &*self.suites[suite.0][pass.0]
     }
 
index f80d6473dcc540109ae1c6025f4a6691f9adcf31..a08fd1f9bf67e820aef96bde1a58fdc075dcce3e 100644 (file)
@@ -928,7 +928,7 @@ macro_rules! try_with_f {
     passes.push_pass(MIR_OPTIMIZED, mir::transform::simplify::SimplifyCfg::new("elaborate-drops"));
 
     // No lifetime analysis based on borrowing can be done from here on out.
-    passes.push_pass(MIR_OPTIMIZED, mir::transform::inline::Inline);
+    // TODO passes.push_pass(MIR_OPTIMIZED, mir::transform::inline::Inline);
     passes.push_pass(MIR_OPTIMIZED, mir::transform::instcombine::InstCombine);
     passes.push_pass(MIR_OPTIMIZED, mir::transform::deaggregator::Deaggregator);
     passes.push_pass(MIR_OPTIMIZED, mir::transform::copy_prop::CopyPropagation);
index e10a91c6ec2e7afb4030cbf4612b62fece9a85e6..2323b55951d7618578bac57893f32f66706c55b3 100644 (file)
@@ -18,7 +18,7 @@
 
 use rustc::dep_graph::DepNode;
 use rustc::mir::*;
-use rustc::mir::transform::{MirCtxt, MirSource, Pass, PassId};
+use rustc::mir::transform::{MirCtxt, MirSource, PassId};
 use rustc::mir::visit::*;
 use rustc::traits;
 use rustc::ty::{self, Ty, TyCtxt};
 
 pub struct Inline;
 
+pub trait Pass {
+    fn run_pass<'a, 'tcx: 'a>(&self, mir_cx: &MirCtxt<'a, 'tcx>)
+                              -> Multi<PassId, &'tcx Steal<Mir<'tcx>>>;
+}
+
 impl Pass for Inline {
     fn run_pass<'a, 'tcx: 'a>(&self, mir_cx: &MirCtxt<'a, 'tcx>)
                               -> Multi<PassId, &'tcx Steal<Mir<'tcx>>> {
index 81af7c239608545635045fd7f066290a00051940..feef7a197c59df346381df6d58da1073d3edc1b6 100644 (file)
@@ -70,15 +70,11 @@ fn mir_pass<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
 
     let mir = pass.run_pass(&mir_ctxt);
 
-    let key = &(suite, pass_num, def_id);
     for hook in passes.hooks() {
-        for (&(_, _, k), v) in mir.iter(key) {
-            let v = &v.borrow();
-            hook.on_mir_pass(&mir_ctxt, Some((k, v)));
-        }
+        hook.on_mir_pass(&mir_ctxt, Some((def_id, &mir)));
     }
 
-    mir
+    Multi::from(tcx.alloc_steal_mir(mir))
 }
 
 struct MirCtxtImpl<'a, 'tcx: 'a> {