Skip to content

Commit c1168be

Browse files
committed
Auto merge of #50282 - fitzgen:run-more-passes-on-constant-mir, r=nikomatsakis
Run more passes on constant mir Not very familiar with this code, but everything seems to be working! r? @eddyb
2 parents a272684 + 1129a71 commit c1168be

File tree

3 files changed

+2
-48
lines changed

3 files changed

+2
-48
lines changed

src/librustc_mir/transform/copy_prop.rs

+1-20
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
//! (non-mutating) use of `SRC`. These restrictions are conservative and may be relaxed in the
3030
//! future.
3131
32-
use rustc::hir;
3332
use rustc::mir::{Constant, Local, LocalKind, Location, Place, Mir, Operand, Rvalue, StatementKind};
3433
use rustc::mir::visit::MutVisitor;
3534
use rustc::ty::TyCtxt;
@@ -41,26 +40,8 @@ pub struct CopyPropagation;
4140
impl MirPass for CopyPropagation {
4241
fn run_pass<'a, 'tcx>(&self,
4342
tcx: TyCtxt<'a, 'tcx, 'tcx>,
44-
source: MirSource,
43+
_source: MirSource,
4544
mir: &mut Mir<'tcx>) {
46-
// Don't run on constant MIR, because trans might not be able to
47-
// evaluate the modified MIR.
48-
// FIXME(eddyb) Remove check after miri is merged.
49-
let id = tcx.hir.as_local_node_id(source.def_id).unwrap();
50-
match (tcx.hir.body_owner_kind(id), source.promoted) {
51-
(_, Some(_)) |
52-
(hir::BodyOwnerKind::Const, _) |
53-
(hir::BodyOwnerKind::Static(_), _) => return,
54-
55-
(hir::BodyOwnerKind::Fn, _) => {
56-
if tcx.is_const_fn(source.def_id) {
57-
// Don't run on const functions, as, again, trans might not be able to evaluate
58-
// the optimized IR.
59-
return
60-
}
61-
}
62-
}
63-
6445
// We only run when the MIR optimization level is > 1.
6546
// This avoids a slow pass, and messing up debug info.
6647
if tcx.sess.opts.debugging_opts.mir_opt_level <= 1 {

src/librustc_mir/transform/deaggregator.rs

+1-20
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
use rustc::hir;
1211
use rustc::ty::TyCtxt;
1312
use rustc::mir::*;
1413
use rustc_data_structures::indexed_vec::Idx;
@@ -19,26 +18,8 @@ pub struct Deaggregator;
1918
impl MirPass for Deaggregator {
2019
fn run_pass<'a, 'tcx>(&self,
2120
tcx: TyCtxt<'a, 'tcx, 'tcx>,
22-
source: MirSource,
21+
_source: MirSource,
2322
mir: &mut Mir<'tcx>) {
24-
// Don't run on constant MIR, because trans might not be able to
25-
// evaluate the modified MIR.
26-
// FIXME(eddyb) Remove check after miri is merged.
27-
let id = tcx.hir.as_local_node_id(source.def_id).unwrap();
28-
match (tcx.hir.body_owner_kind(id), source.promoted) {
29-
(_, Some(_)) |
30-
(hir::BodyOwnerKind::Const, _) |
31-
(hir::BodyOwnerKind::Static(_), _) => return,
32-
33-
(hir::BodyOwnerKind::Fn, _) => {
34-
if tcx.is_const_fn(source.def_id) {
35-
// Don't run on const functions, as, again, trans might not be able to evaluate
36-
// the optimized IR.
37-
return
38-
}
39-
}
40-
}
41-
4223
let (basic_blocks, local_decls) = mir.basic_blocks_and_local_decls_mut();
4324
let local_decls = &*local_decls;
4425
for bb in basic_blocks {

src/librustc_mir/transform/elaborate_drops.rs

-8
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use dataflow::{on_all_children_bits, on_all_drop_children_bits};
1515
use dataflow::{drop_flag_effects_for_location, on_lookup_result_bits};
1616
use dataflow::MoveDataParamEnv;
1717
use dataflow::{self, do_dataflow, DebugFormatted};
18-
use rustc::hir;
1918
use rustc::ty::{self, TyCtxt};
2019
use rustc::mir::*;
2120
use rustc::middle::const_val::ConstVal;
@@ -42,14 +41,7 @@ impl MirPass for ElaborateDrops {
4241
{
4342
debug!("elaborate_drops({:?} @ {:?})", src, mir.span);
4443

45-
// Don't run on constant MIR, because trans might not be able to
46-
// evaluate the modified MIR.
47-
// FIXME(eddyb) Remove check after miri is merged.
4844
let id = tcx.hir.as_local_node_id(src.def_id).unwrap();
49-
match (tcx.hir.body_owner_kind(id), src.promoted) {
50-
(hir::BodyOwnerKind::Fn, None) => {},
51-
_ => return
52-
}
5345
let param_env = tcx.param_env(src.def_id).with_reveal_all();
5446
let move_data = MoveData::gather_moves(mir, tcx).unwrap();
5547
let elaborate_patch = {

0 commit comments

Comments
 (0)