Skip to content

Commit a94d1e7

Browse files
committed
rustc_mir: enable the deaggregate pass by default.
1 parent 534968e commit a94d1e7

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/librustc_mir/transform/deaggregator.rs

+12-11
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,23 @@ impl MirPass for Deaggregator {
2121
tcx: TyCtxt<'a, 'tcx, 'tcx>,
2222
source: MirSource,
2323
mir: &mut Mir<'tcx>) {
24-
let node_path = tcx.item_path_str(source.def_id);
25-
debug!("running on: {:?}", node_path);
26-
// we only run when mir_opt_level > 2
27-
if tcx.sess.opts.debugging_opts.mir_opt_level <= 2 {
28-
return;
29-
}
30-
3124
// Don't run on constant MIR, because trans might not be able to
3225
// evaluate the modified MIR.
3326
// FIXME(eddyb) Remove check after miri is merged.
3427
let id = tcx.hir.as_local_node_id(source.def_id).unwrap();
3528
match (tcx.hir.body_owner_kind(id), source.promoted) {
36-
(hir::BodyOwnerKind::Fn, None) => {},
37-
_ => return
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+
}
3840
}
39-
// In fact, we might not want to trigger in other cases.
40-
// Ex: when we could use SROA. See issue #35259
4141

4242
for bb in mir.basic_blocks_mut() {
4343
let mut curr: usize = 0;
@@ -107,6 +107,7 @@ impl MirPass for Deaggregator {
107107
}
108108
}
109109

110+
// FIXME(eddyb) clean up and support all aggregates.
110111
fn get_aggregate_statement_index<'a, 'tcx, 'b>(start: usize,
111112
statements: &Vec<Statement<'tcx>>)
112113
-> Option<usize> {

0 commit comments

Comments
 (0)