about summary refs log tree commit diff
path: root/src/librustc_mir/transform
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2016-12-12 10:19:14 +0000
committerbors <bors@rust-lang.org>2016-12-12 10:19:14 +0000
commit0eae43e4d00ca6697da59b84c7cdf1c8ea83ea00 (patch)
treebe9e110e0816398427b050312258649a0e071a82 /src/librustc_mir/transform
parent8d66181b5e35295deea24c389db5366d0776f7f8 (diff)
parent6d46a21cb3fd6d9c238fb979b5f071285f23e919 (diff)
downloadrust-0eae43e4d00ca6697da59b84c7cdf1c8ea83ea00.tar.gz
rust-0eae43e4d00ca6697da59b84c7cdf1c8ea83ea00.zip
Auto merge of #38307 - bluss:mir-opt-level, r=eddyb
Simplify use of mir_opt_level

Remove the unused top level option by the same name, and retain the
debug option.

Use -Zmir-opt-level=1 as default.

One pass is enabled by default but wants to be optional:

- Instcombine requires mir_opt_level > 0

Copy propagation is not used by default, but used to be activated by
explicit -Zmir-opt-level=1. It must move one higher to be off by
default:

- CopyPropagation requires mir_opt_level > 1

Deaggregate is not used by default, and used to be on a different level
than CopyPropagation:

- Deaggreate requires mir_opt_level > 2
Diffstat (limited to 'src/librustc_mir/transform')
-rw-r--r--src/librustc_mir/transform/copy_prop.rs9
-rw-r--r--src/librustc_mir/transform/deaggregator.rs11
-rw-r--r--src/librustc_mir/transform/instcombine.rs2
3 files changed, 9 insertions, 13 deletions
diff --git a/src/librustc_mir/transform/copy_prop.rs b/src/librustc_mir/transform/copy_prop.rs
index 8c8c42a1c76..d16b51adbaf 100644
--- a/src/librustc_mir/transform/copy_prop.rs
+++ b/src/librustc_mir/transform/copy_prop.rs
@@ -65,11 +65,10 @@ impl<'tcx> MirPass<'tcx> for CopyPropagation {
             }
         }
 
-        // We only run when the MIR optimization level is at least 1. This avoids messing up debug
-        // info.
-        match tcx.sess.opts.debugging_opts.mir_opt_level {
-            Some(0) | None => return,
-            _ => {}
+        // We only run when the MIR optimization level is > 1.
+        // This avoids a slow pass, and messing up debug info.
+        if tcx.sess.opts.debugging_opts.mir_opt_level <= 1 {
+            return;
         }
 
         loop {
diff --git a/src/librustc_mir/transform/deaggregator.rs b/src/librustc_mir/transform/deaggregator.rs
index e13c8e02137..771f05f7bcc 100644
--- a/src/librustc_mir/transform/deaggregator.rs
+++ b/src/librustc_mir/transform/deaggregator.rs
@@ -23,13 +23,10 @@ impl<'tcx> MirPass<'tcx> for Deaggregator {
         let node_id = source.item_id();
         let node_path = tcx.item_path_str(tcx.map.local_def_id(node_id));
         debug!("running on: {:?}", node_path);
-        // we only run when mir_opt_level > 1
-        match tcx.sess.opts.debugging_opts.mir_opt_level {
-            Some(0) |
-            Some(1) |
-            None => { return; },
-            _ => {}
-        };
+        // we only run when mir_opt_level > 2
+        if tcx.sess.opts.debugging_opts.mir_opt_level <= 2 {
+            return;
+        }
 
         // Do not trigger on constants.  Could be revised in future
         if let MirSource::Fn(_) = source {} else { return; }
diff --git a/src/librustc_mir/transform/instcombine.rs b/src/librustc_mir/transform/instcombine.rs
index c4a8d34bda0..3f6abb31fe9 100644
--- a/src/librustc_mir/transform/instcombine.rs
+++ b/src/librustc_mir/transform/instcombine.rs
@@ -38,7 +38,7 @@ impl<'tcx> MirPass<'tcx> for InstCombine {
                     _: MirSource,
                     mir: &mut Mir<'tcx>) {
         // We only run when optimizing MIR (at any level).
-        if tcx.sess.opts.debugging_opts.mir_opt_level == Some(0) {
+        if tcx.sess.opts.debugging_opts.mir_opt_level == 0 {
             return
         }