Skip to content

Commit c253df5

Browse files
committed
remove Pass and (temporarily) drop Inline
1 parent 69c8f9d commit c253df5

File tree

4 files changed

+12
-37
lines changed

4 files changed

+12
-37
lines changed

src/librustc/mir/transform.rs

+3-29
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ use hir::def_id::DefId;
1515
use hir::map::DefPathData;
1616
use mir::{Mir, Promoted};
1717
use ty::TyCtxt;
18-
use ty::maps::Multi;
19-
use ty::steal::Steal;
2018
use std::cell::Ref;
2119
use std::rc::Rc;
2220
use syntax::ast::NodeId;
@@ -135,19 +133,6 @@ pub trait PassHook {
135133
/// application of a pass to a def-id.
136134
pub type PassId = (MirSuite, MirPassIndex, DefId);
137135

138-
/// The most generic sort of MIR pass. You only want to implement this
139-
/// rather general trait if you are doing an interprocedural pass that
140-
/// may inspect and affect the MIR of many def-ids. Otherwise, prefer
141-
/// the more steamlined `DefIdPass` or `MirPass`.
142-
pub trait Pass {
143-
fn name<'a>(&'a self) -> Cow<'a, str> {
144-
default_name::<Self>()
145-
}
146-
147-
fn run_pass<'a, 'tcx: 'a>(&self, mir_cx: &MirCtxt<'a, 'tcx>)
148-
-> Multi<PassId, &'tcx Steal<Mir<'tcx>>>;
149-
}
150-
151136
/// A streamlined trait that you can implement to create an
152137
/// intraprocedural pass; the pass will be invoked to process the MIR
153138
/// with the given `def_id`. This lets you do things before we fetch
@@ -160,17 +145,6 @@ pub trait DefIdPass {
160145
fn run_pass<'a, 'tcx: 'a>(&self, mir_cx: &MirCtxt<'a, 'tcx>) -> Mir<'tcx>;
161146
}
162147

163-
impl<T: DefIdPass> Pass for T {
164-
fn name<'a>(&'a self) -> Cow<'a, str> {
165-
DefIdPass::name(self)
166-
}
167-
168-
fn run_pass<'a, 'tcx: 'a>(&self, mir_cx: &MirCtxt<'a, 'tcx>)
169-
-> Multi<PassId, &'tcx Steal<Mir<'tcx>>> {
170-
Multi::from(mir_cx.tcx().alloc_steal_mir(DefIdPass::run_pass(self, mir_cx)))
171-
}
172-
}
173-
174148
/// A streamlined trait that you can implement to create a pass; the
175149
/// pass will be named after the type, and it will consist of a main
176150
/// loop that goes over each available MIR and applies `run_pass`.
@@ -210,7 +184,7 @@ impl<T: MirPass> DefIdPass for T {
210184
#[derive(Clone)]
211185
pub struct Passes {
212186
pass_hooks: Vec<Rc<PassHook>>,
213-
suites: Vec<Vec<Rc<Pass>>>,
187+
suites: Vec<Vec<Rc<DefIdPass>>>,
214188
}
215189

216190
/// The number of "pass suites" that we have:
@@ -238,7 +212,7 @@ impl<'a, 'tcx> Passes {
238212
}
239213

240214
/// Pushes a built-in pass.
241-
pub fn push_pass<T: Pass + 'static>(&mut self, suite: MirSuite, pass: T) {
215+
pub fn push_pass<T: DefIdPass + 'static>(&mut self, suite: MirSuite, pass: T) {
242216
self.suites[suite.0].push(Rc::new(pass));
243217
}
244218

@@ -251,7 +225,7 @@ impl<'a, 'tcx> Passes {
251225
self.suites[suite.0].len()
252226
}
253227

254-
pub fn pass(&self, suite: MirSuite, pass: MirPassIndex) -> &Pass {
228+
pub fn pass(&self, suite: MirSuite, pass: MirPassIndex) -> &DefIdPass {
255229
&*self.suites[suite.0][pass.0]
256230
}
257231

src/librustc_driver/driver.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -928,7 +928,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
928928
passes.push_pass(MIR_OPTIMIZED, mir::transform::simplify::SimplifyCfg::new("elaborate-drops"));
929929

930930
// No lifetime analysis based on borrowing can be done from here on out.
931-
passes.push_pass(MIR_OPTIMIZED, mir::transform::inline::Inline);
931+
// TODO passes.push_pass(MIR_OPTIMIZED, mir::transform::inline::Inline);
932932
passes.push_pass(MIR_OPTIMIZED, mir::transform::instcombine::InstCombine);
933933
passes.push_pass(MIR_OPTIMIZED, mir::transform::deaggregator::Deaggregator);
934934
passes.push_pass(MIR_OPTIMIZED, mir::transform::copy_prop::CopyPropagation);

src/librustc_mir/transform/inline.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc_data_structures::graph;
1818

1919
use rustc::dep_graph::DepNode;
2020
use rustc::mir::*;
21-
use rustc::mir::transform::{MirCtxt, MirSource, Pass, PassId};
21+
use rustc::mir::transform::{MirCtxt, MirSource, PassId};
2222
use rustc::mir::visit::*;
2323
use rustc::traits;
2424
use rustc::ty::{self, Ty, TyCtxt};
@@ -45,6 +45,11 @@ const UNKNOWN_SIZE_COST: usize = 10;
4545

4646
pub struct Inline;
4747

48+
pub trait Pass {
49+
fn run_pass<'a, 'tcx: 'a>(&self, mir_cx: &MirCtxt<'a, 'tcx>)
50+
-> Multi<PassId, &'tcx Steal<Mir<'tcx>>>;
51+
}
52+
4853
impl Pass for Inline {
4954
fn run_pass<'a, 'tcx: 'a>(&self, mir_cx: &MirCtxt<'a, 'tcx>)
5055
-> Multi<PassId, &'tcx Steal<Mir<'tcx>>> {

src/librustc_mir/transform/mod.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,11 @@ fn mir_pass<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
7070

7171
let mir = pass.run_pass(&mir_ctxt);
7272

73-
let key = &(suite, pass_num, def_id);
7473
for hook in passes.hooks() {
75-
for (&(_, _, k), v) in mir.iter(key) {
76-
let v = &v.borrow();
77-
hook.on_mir_pass(&mir_ctxt, Some((k, v)));
78-
}
74+
hook.on_mir_pass(&mir_ctxt, Some((def_id, &mir)));
7975
}
8076

81-
mir
77+
Multi::from(tcx.alloc_steal_mir(mir))
8278
}
8379

8480
struct MirCtxtImpl<'a, 'tcx: 'a> {

0 commit comments

Comments
 (0)