Skip to content

Commit 937f9ba

Browse files
committed
mir: Run copy propagation on constant mir
Now that miri is merged, this seems to Just Work!
1 parent ada45fd commit 937f9ba

File tree

1 file changed

+1
-20
lines changed

1 file changed

+1
-20
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 {

0 commit comments

Comments
 (0)