about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEduard-Mihai Burtescu <edy.burt@gmail.com>2018-02-07 14:36:03 +0200
committerEduard-Mihai Burtescu <edy.burt@gmail.com>2018-02-20 02:50:26 +0200
commit3922dd72fe98ecc8866d448fe1e637971a46341a (patch)
tree0c931a1a7d4fad0faad1a778910b8a5edca5afe0 /src
parent27a046e9338fb0455c33b13e8fe28da78212dedc (diff)
rustc_mir: use the "idiomatic" optimization gating in the deaggregator.
Diffstat (limited to 'src')
-rw-r--r--src/librustc_mir/transform/deaggregator.rs27
1 files changed, 16 insertions, 11 deletions
diff --git a/src/librustc_mir/transform/deaggregator.rs b/src/librustc_mir/transform/deaggregator.rs
index eccb0d231b8..ea27d789248 100644
--- a/src/librustc_mir/transform/deaggregator.rs
+++ b/src/librustc_mir/transform/deaggregator.rs
@@ -21,23 +21,28 @@ impl MirPass for Deaggregator {
                           tcx: TyCtxt<'a, 'tcx, 'tcx>,
                           source: MirSource,
                           mir: &mut Mir<'tcx>) {
-        let node_path = tcx.item_path_str(source.def_id);
-        debug!("running on: {:?}", node_path);
-        // we only run when mir_opt_level > 2
-        if tcx.sess.opts.debugging_opts.mir_opt_level <= 2 {
-            return;
-        }
-
         // Don't run on constant MIR, because trans might not be able to
         // evaluate the modified MIR.
         // FIXME(eddyb) Remove check after miri is merged.
         let id = tcx.hir.as_local_node_id(source.def_id).unwrap();
         match (tcx.hir.body_owner_kind(id), source.promoted) {
-            (hir::BodyOwnerKind::Fn, None) => {},
-            _ => return
+            (_, Some(_)) |
+            (hir::BodyOwnerKind::Const, _) |
+            (hir::BodyOwnerKind::Static(_), _) => return,
+
+            (hir::BodyOwnerKind::Fn, _) => {
+                if tcx.is_const_fn(source.def_id) {
+                    // Don't run on const functions, as, again, trans might not be able to evaluate
+                    // the optimized IR.
+                    return
+                }
+            }
+        }
+
+        // We only run when the MIR optimization level is > 2.
+        if tcx.sess.opts.debugging_opts.mir_opt_level <= 2 {
+            return;
         }
-        // In fact, we might not want to trigger in other cases.
-        // Ex: when we could use SROA.  See issue #35259
 
         for bb in mir.basic_blocks_mut() {
             let mut curr: usize = 0;