1
Fork 0

Rollup merge of #82736 - spastorino:mir-opt-level-perf-changes, r=oli-obk

Bump optimization from mir_opt_level 2 to 3 and 3 to 4 and make "release" be level 2 by default

r? `@oli-obk`
This commit is contained in:
Guillaume Gomez 2021-03-05 21:44:40 +01:00 committed by GitHub
commit 15c148b4f2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
85 changed files with 117 additions and 109 deletions

View file

@ -566,7 +566,7 @@ fn test_debugging_options_tracking_hash() {
tracked!(link_only, true); tracked!(link_only, true);
tracked!(merge_functions, Some(MergeFunctions::Disabled)); tracked!(merge_functions, Some(MergeFunctions::Disabled));
tracked!(mir_emit_retag, true); tracked!(mir_emit_retag, true);
tracked!(mir_opt_level, 3); tracked!(mir_opt_level, Some(4));
tracked!(mutable_noalias, true); tracked!(mutable_noalias, true);
tracked!(new_llvm_pass_manager, true); tracked!(new_llvm_pass_manager, true);
tracked!(no_codegen, true); tracked!(no_codegen, true);

View file

@ -28,7 +28,7 @@ pub struct ConstGoto;
impl<'tcx> MirPass<'tcx> for ConstGoto { impl<'tcx> MirPass<'tcx> for ConstGoto {
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
if tcx.sess.opts.debugging_opts.mir_opt_level < 3 { if tcx.sess.mir_opt_level() < 4 {
return; return;
} }
trace!("Running ConstGoto on {:?}", body.source); trace!("Running ConstGoto on {:?}", body.source);

View file

@ -725,7 +725,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
return None; return None;
} }
if self.tcx.sess.opts.debugging_opts.mir_opt_level >= 3 { if self.tcx.sess.mir_opt_level() >= 4 {
self.eval_rvalue_with_identities(rvalue, place) self.eval_rvalue_with_identities(rvalue, place)
} else { } else {
self.use_ecx(|this| this.ecx.eval_rvalue_into_place(rvalue, place)) self.use_ecx(|this| this.ecx.eval_rvalue_into_place(rvalue, place))
@ -903,7 +903,7 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
/// Returns `true` if and only if this `op` should be const-propagated into. /// Returns `true` if and only if this `op` should be const-propagated into.
fn should_const_prop(&mut self, op: &OpTy<'tcx>) -> bool { fn should_const_prop(&mut self, op: &OpTy<'tcx>) -> bool {
let mir_opt_level = self.tcx.sess.opts.debugging_opts.mir_opt_level; let mir_opt_level = self.tcx.sess.mir_opt_level();
if mir_opt_level == 0 { if mir_opt_level == 0 {
return false; return false;
@ -1071,9 +1071,9 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
fn visit_operand(&mut self, operand: &mut Operand<'tcx>, location: Location) { fn visit_operand(&mut self, operand: &mut Operand<'tcx>, location: Location) {
self.super_operand(operand, location); self.super_operand(operand, location);
// Only const prop copies and moves on `mir_opt_level=2` as doing so // Only const prop copies and moves on `mir_opt_level=3` as doing so
// currently slightly increases compile time in some cases. // currently slightly increases compile time in some cases.
if self.tcx.sess.opts.debugging_opts.mir_opt_level >= 2 { if self.tcx.sess.mir_opt_level() >= 3 {
self.propagate_operand(operand) self.propagate_operand(operand)
} }
} }
@ -1253,7 +1253,7 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
TerminatorKind::SwitchInt { ref mut discr, .. } => { TerminatorKind::SwitchInt { ref mut discr, .. } => {
// FIXME: This is currently redundant with `visit_operand`, but sadly // FIXME: This is currently redundant with `visit_operand`, but sadly
// always visiting operands currently causes a perf regression in LLVM codegen, so // always visiting operands currently causes a perf regression in LLVM codegen, so
// `visit_operand` currently only runs for propagates places for `mir_opt_level=3`. // `visit_operand` currently only runs for propagates places for `mir_opt_level=4`.
self.propagate_operand(discr) self.propagate_operand(discr)
} }
// None of these have Operands to const-propagate. // None of these have Operands to const-propagate.
@ -1272,7 +1272,7 @@ impl<'mir, 'tcx> MutVisitor<'tcx> for ConstPropagator<'mir, 'tcx> {
// Every argument in our function calls have already been propagated in `visit_operand`. // Every argument in our function calls have already been propagated in `visit_operand`.
// //
// NOTE: because LLVM codegen gives slight performance regressions with it, so this is // NOTE: because LLVM codegen gives slight performance regressions with it, so this is
// gated on `mir_opt_level=2`. // gated on `mir_opt_level=3`.
TerminatorKind::Call { .. } => {} TerminatorKind::Call { .. } => {}
} }

View file

@ -16,7 +16,7 @@ pub struct DeduplicateBlocks;
impl<'tcx> MirPass<'tcx> for DeduplicateBlocks { impl<'tcx> MirPass<'tcx> for DeduplicateBlocks {
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
if tcx.sess.opts.debugging_opts.mir_opt_level < 3 { if tcx.sess.mir_opt_level() < 4 {
return; return;
} }
debug!("Running DeduplicateBlocks on `{:?}`", body.source); debug!("Running DeduplicateBlocks on `{:?}`", body.source);

View file

@ -127,9 +127,9 @@ pub struct DestinationPropagation;
impl<'tcx> MirPass<'tcx> for DestinationPropagation { impl<'tcx> MirPass<'tcx> for DestinationPropagation {
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
// Only run at mir-opt-level=2 or higher for now (we don't fix up debuginfo and remove // Only run at mir-opt-level=3 or higher for now (we don't fix up debuginfo and remove
// storage statements at the moment). // storage statements at the moment).
if tcx.sess.opts.debugging_opts.mir_opt_level <= 1 { if tcx.sess.mir_opt_level() < 3 {
return; return;
} }

View file

@ -26,7 +26,7 @@ pub struct EarlyOtherwiseBranch;
impl<'tcx> MirPass<'tcx> for EarlyOtherwiseBranch { impl<'tcx> MirPass<'tcx> for EarlyOtherwiseBranch {
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
if tcx.sess.opts.debugging_opts.mir_opt_level < 2 { if tcx.sess.mir_opt_level() < 3 {
return; return;
} }
trace!("running EarlyOtherwiseBranch on {:?}", body.source); trace!("running EarlyOtherwiseBranch on {:?}", body.source);

View file

@ -52,7 +52,7 @@ crate fn is_enabled(tcx: TyCtxt<'_>) -> bool {
return enabled; return enabled;
} }
tcx.sess.opts.debugging_opts.mir_opt_level >= 2 tcx.sess.mir_opt_level() >= 3
} }
impl<'tcx> MirPass<'tcx> for Inline { impl<'tcx> MirPass<'tcx> for Inline {

View file

@ -40,7 +40,7 @@ pub struct MatchBranchSimplification;
impl<'tcx> MirPass<'tcx> for MatchBranchSimplification { impl<'tcx> MirPass<'tcx> for MatchBranchSimplification {
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
if tcx.sess.opts.debugging_opts.mir_opt_level <= 1 { if tcx.sess.mir_opt_level() < 3 {
return; return;
} }

View file

@ -475,7 +475,7 @@ fn run_post_borrowck_cleanup_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tc
} }
fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
let mir_opt_level = tcx.sess.opts.debugging_opts.mir_opt_level; let mir_opt_level = tcx.sess.mir_opt_level();
// Lowering generator control-flow and variables has to happen before we do anything else // Lowering generator control-flow and variables has to happen before we do anything else
// to them. We run some optimizations before that, because they may be harder to do on the state // to them. We run some optimizations before that, because they may be harder to do on the state

View file

@ -10,7 +10,7 @@ pub struct MultipleReturnTerminators;
impl<'tcx> MirPass<'tcx> for MultipleReturnTerminators { impl<'tcx> MirPass<'tcx> for MultipleReturnTerminators {
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
if tcx.sess.opts.debugging_opts.mir_opt_level < 3 { if tcx.sess.mir_opt_level() < 4 {
return; return;
} }

View file

@ -34,7 +34,7 @@ pub struct RenameReturnPlace;
impl<'tcx> MirPass<'tcx> for RenameReturnPlace { impl<'tcx> MirPass<'tcx> for RenameReturnPlace {
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut mir::Body<'tcx>) { fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut mir::Body<'tcx>) {
if tcx.sess.opts.debugging_opts.mir_opt_level == 0 { if tcx.sess.mir_opt_level() == 0 {
return; return;
} }

View file

@ -12,8 +12,8 @@ pub struct UnreachablePropagation;
impl MirPass<'_> for UnreachablePropagation { impl MirPass<'_> for UnreachablePropagation {
fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { fn run_pass<'tcx>(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
if tcx.sess.opts.debugging_opts.mir_opt_level < 3 { if tcx.sess.mir_opt_level() < 4 {
// Enable only under -Zmir-opt-level=3 as in some cases (check the deeply-nested-opt // Enable only under -Zmir-opt-level=4 as in some cases (check the deeply-nested-opt
// perf benchmark) LLVM may spend quite a lot of time optimizing the generated code. // perf benchmark) LLVM may spend quite a lot of time optimizing the generated code.
return; return;
} }

View file

@ -1938,21 +1938,23 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
Some(SymbolManglingVersion::V0) => {} Some(SymbolManglingVersion::V0) => {}
} }
if debugging_opts.mir_opt_level > 1 { if let Some(mir_opt_level) = debugging_opts.mir_opt_level {
// Functions inlined during MIR transform can, at best, make it impossible to if mir_opt_level > 1 {
// effectively cover inlined functions, and, at worst, break coverage map generation // Functions inlined during MIR transform can, at best, make it impossible to
// during LLVM codegen. For example, function counter IDs are only unique within a // effectively cover inlined functions, and, at worst, break coverage map generation
// function. Inlining after these counters are injected can produce duplicate counters, // during LLVM codegen. For example, function counter IDs are only unique within a
// resulting in an invalid coverage map (and ICE); so this option combination is not // function. Inlining after these counters are injected can produce duplicate counters,
// allowed. // resulting in an invalid coverage map (and ICE); so this option combination is not
early_warn( // allowed.
error_format, early_warn(
&format!( error_format,
"`-Z mir-opt-level={}` (or any level > 1) enables function inlining, which \ &format!(
"`-Z mir-opt-level={}` (or any level > 1) enables function inlining, which \
is incompatible with `-Z instrument-coverage`. Inlining will be disabled.", is incompatible with `-Z instrument-coverage`. Inlining will be disabled.",
debugging_opts.mir_opt_level, mir_opt_level,
), ),
); );
}
} }
} }

View file

@ -999,8 +999,8 @@ options! {DebuggingOptions, DebuggingSetter, basic_debugging_options,
mir_emit_retag: bool = (false, parse_bool, [TRACKED], mir_emit_retag: bool = (false, parse_bool, [TRACKED],
"emit Retagging MIR statements, interpreted e.g., by miri; implies -Zmir-opt-level=0 \ "emit Retagging MIR statements, interpreted e.g., by miri; implies -Zmir-opt-level=0 \
(default: no)"), (default: no)"),
mir_opt_level: usize = (1, parse_uint, [TRACKED], mir_opt_level: Option<usize> = (None, parse_opt_uint, [TRACKED],
"MIR optimization level (0-3; default: 1)"), "MIR optimization level (0-4; default: 1 in non optimized builds and 2 in optimized builds)"),
mutable_noalias: bool = (false, parse_bool, [TRACKED], mutable_noalias: bool = (false, parse_bool, [TRACKED],
"emit noalias metadata for mutable references (default: no)"), "emit noalias metadata for mutable references (default: no)"),
new_llvm_pass_manager: bool = (false, parse_bool, [TRACKED], new_llvm_pass_manager: bool = (false, parse_bool, [TRACKED],

View file

@ -640,6 +640,12 @@ impl Session {
pub fn binary_dep_depinfo(&self) -> bool { pub fn binary_dep_depinfo(&self) -> bool {
self.opts.debugging_opts.binary_dep_depinfo self.opts.debugging_opts.binary_dep_depinfo
} }
pub fn mir_opt_level(&self) -> usize {
self.opts
.debugging_opts
.mir_opt_level
.unwrap_or_else(|| if self.opts.optimize != config::OptLevel::No { 2 } else { 1 })
}
/// Gets the features enabled for the current compilation session. /// Gets the features enabled for the current compilation session.
/// DO NOT USE THIS METHOD if there is a TyCtxt available, as it circumvents /// DO NOT USE THIS METHOD if there is a TyCtxt available, as it circumvents

View file

@ -5,8 +5,8 @@
// Once the optimizer can do that, mir-opt/issues/issue-59352.rs will need to be updated and this // Once the optimizer can do that, mir-opt/issues/issue-59352.rs will need to be updated and this
// test case should be removed as it will become redundant. // test case should be removed as it will become redundant.
// mir-opt-level=2 enables inlining and enables LLVM to optimize away the unreachable panic call. // mir-opt-level=3 enables inlining and enables LLVM to optimize away the unreachable panic call.
// compile-flags: -O -Z mir-opt-level=2 // compile-flags: -O -Z mir-opt-level=3
#![crate_type = "rlib"] #![crate_type = "rlib"]

View file

@ -1,5 +1,5 @@
// Checks that naked functions are never inlined. // Checks that naked functions are never inlined.
// compile-flags: -O -Zmir-opt-level=2 // compile-flags: -O -Zmir-opt-level=3
// ignore-wasm32 // ignore-wasm32
#![crate_type = "lib"] #![crate_type = "lib"]
#![feature(asm)] #![feature(asm)]

View file

@ -4,8 +4,8 @@
// needs-sanitizer-address // needs-sanitizer-address
// needs-sanitizer-leak // needs-sanitizer-leak
// revisions: ASAN LSAN // revisions: ASAN LSAN
//[ASAN] compile-flags: -Zsanitizer=address -C opt-level=3 -Z mir-opt-level=3 //[ASAN] compile-flags: -Zsanitizer=address -C opt-level=3 -Z mir-opt-level=4
//[LSAN] compile-flags: -Zsanitizer=leak -C opt-level=3 -Z mir-opt-level=3 //[LSAN] compile-flags: -Zsanitizer=leak -C opt-level=3 -Z mir-opt-level=4
#![crate_type="lib"] #![crate_type="lib"]
#![feature(no_sanitize)] #![feature(no_sanitize)]

View file

@ -1,4 +1,4 @@
// compile-flags: -C no-prepopulate-passes -O -Z mir-opt-level=2 -Zunsound-mir-opts // compile-flags: -C no-prepopulate-passes -O -Z mir-opt-level=3 -Zunsound-mir-opts
// Ensure that `x?` has no overhead on `Result<T, E>` due to identity `match`es in lowering. // Ensure that `x?` has no overhead on `Result<T, E>` due to identity `match`es in lowering.
// This requires inlining to trigger the MIR optimizations in `SimplifyArmIdentity`. // This requires inlining to trigger the MIR optimizations in `SimplifyArmIdentity`.

View file

@ -1,4 +1,4 @@
// compile-flags: -O -Zmir-opt-level=3 // compile-flags: -O -Zmir-opt-level=4
// EMIT_MIR boolean_identities.test.ConstProp.diff // EMIT_MIR boolean_identities.test.ConstProp.diff
pub fn test(x: bool, y: bool) -> bool { pub fn test(x: bool, y: bool) -> bool {

View file

@ -1,4 +1,4 @@
// compile-flags: -Z mir-opt-level=2 // compile-flags: -Z mir-opt-level=3
// Due to a bug in propagating scalar pairs the assertion below used to fail. In the expected // Due to a bug in propagating scalar pairs the assertion below used to fail. In the expected
// outputs below, after ConstProp this is how _2 would look like with the bug: // outputs below, after ConstProp this is how _2 would look like with the bug:

View file

@ -1,4 +1,4 @@
// compile-flags: -Z mir-opt-level=2 // compile-flags: -Z mir-opt-level=3
// This used to ICE in const-prop // This used to ICE in const-prop

View file

@ -1,4 +1,4 @@
// compile-flags: -O -Zmir-opt-level=3 // compile-flags: -O -Zmir-opt-level=4
// EMIT_MIR mult_by_zero.test.ConstProp.diff // EMIT_MIR mult_by_zero.test.ConstProp.diff
fn test(x : i32) -> i32 { fn test(x : i32) -> i32 {

View file

@ -1,4 +1,4 @@
// compile-flags: -Z mir-opt-level=3 // compile-flags: -Z mir-opt-level=4
// EMIT_MIR early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff // EMIT_MIR early_otherwise_branch.opt1.EarlyOtherwiseBranch.diff
fn opt1(x: Option<u32>, y: Option<u32>) -> u32 { fn opt1(x: Option<u32>, y: Option<u32>) -> u32 {
match (x, y) { match (x, y) {

View file

@ -1,4 +1,4 @@
// compile-flags: -Z mir-opt-level=3 // compile-flags: -Z mir-opt-level=4
// EMIT_MIR early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff // EMIT_MIR early_otherwise_branch_3_element_tuple.opt1.EarlyOtherwiseBranch.diff
fn opt1(x: Option<u32>, y: Option<u32>, z: Option<u32>) -> u32 { fn opt1(x: Option<u32>, y: Option<u32>, z: Option<u32>) -> u32 {

View file

@ -1,5 +1,5 @@
// ignore-tidy-linelength // ignore-tidy-linelength
// compile-flags: -Z mir-opt-level=3 -Zunsound-mir-opts // compile-flags: -Z mir-opt-level=4 -Zunsound-mir-opts
// example from #68867 // example from #68867
type CSSFloat = f32; type CSSFloat = f32;

View file

@ -1,4 +1,4 @@
// compile-flags: -Z mir-opt-level=3 // compile-flags: -Z mir-opt-level=4
// must not optimize as it does not follow the pattern of // must not optimize as it does not follow the pattern of
// left and right hand side being the same variant // left and right hand side being the same variant

View file

@ -1,6 +1,6 @@
// ignore-endian-big // ignore-endian-big
// ignore-wasm32-bare compiled with panic=abort by default // ignore-wasm32-bare compiled with panic=abort by default
// compile-flags: -Z mir-opt-level=3 // compile-flags: -Z mir-opt-level=4
// EMIT_MIR_FOR_EACH_BIT_WIDTH // EMIT_MIR_FOR_EACH_BIT_WIDTH
#![feature(box_syntax)] #![feature(box_syntax)]
// EMIT_MIR inline_into_box_place.main.Inline.diff // EMIT_MIR inline_into_box_place.main.Inline.diff

View file

@ -1,4 +1,4 @@
// compile-flags: -Z span_free_formats -Z mir-opt-level=3 // compile-flags: -Z span_free_formats -Z mir-opt-level=4
// EMIT_MIR inline_trait_method_2.test2.Inline.after.mir // EMIT_MIR inline_trait_method_2.test2.Inline.after.mir
fn test2(x: &dyn X) -> bool { fn test2(x: &dyn X) -> bool {

View file

@ -7,7 +7,7 @@
// removed. // removed.
// EMIT_MIR issue_59352.num_to_digit.PreCodegen.after.mir // EMIT_MIR issue_59352.num_to_digit.PreCodegen.after.mir
// compile-flags: -Z mir-opt-level=2 -Z span_free_formats // compile-flags: -Z mir-opt-level=3 -Z span_free_formats
pub fn num_to_digit(num: char) -> u32 { pub fn num_to_digit(num: char) -> u32 {
// CHECK-NOT: panic // CHECK-NOT: panic

View file

@ -1,4 +1,4 @@
// compile-flags: -Z mir-opt-level=3 // compile-flags: -Z mir-opt-level=4
// EMIT_MIR multiple_return_terminators.test.MultipleReturnTerminators.diff // EMIT_MIR multiple_return_terminators.test.MultipleReturnTerminators.diff
fn test(x: bool) { fn test(x: bool) {

View file

@ -1,7 +1,7 @@
// Checks that `SimplifyArmIdentity` is not applied if enums have incompatible layouts. // Checks that `SimplifyArmIdentity` is not applied if enums have incompatible layouts.
// Regression test for issue #66856. // Regression test for issue #66856.
// //
// compile-flags: -Zmir-opt-level=2 // compile-flags: -Zmir-opt-level=3
// EMIT_MIR_FOR_EACH_BIT_WIDTH // EMIT_MIR_FOR_EACH_BIT_WIDTH
enum Src { enum Src {

View file

@ -1,4 +1,4 @@
// compile-flags: -Z mir-opt-level=2 -Zunsound-mir-opts // compile-flags: -Z mir-opt-level=3 -Zunsound-mir-opts
// EMIT_MIR simplify_arm.id.SimplifyArmIdentity.diff // EMIT_MIR simplify_arm.id.SimplifyArmIdentity.diff
// EMIT_MIR simplify_arm.id.SimplifyBranchSame.diff // EMIT_MIR simplify_arm.id.SimplifyBranchSame.diff
// EMIT_MIR simplify_arm.id_result.SimplifyArmIdentity.diff // EMIT_MIR simplify_arm.id_result.SimplifyArmIdentity.diff

View file

@ -1,4 +1,4 @@
// compile-flags: -Zmir-opt-level=3 // compile-flags: -Zmir-opt-level=4
// run-pass // run-pass
#![feature(const_generics)] #![feature(const_generics)]

View file

@ -1,5 +1,5 @@
// build-fail // build-fail
// compile-flags: -Zmir-opt-level=2 // compile-flags: -Zmir-opt-level=3
#![deny(warnings)] #![deny(warnings)]

View file

@ -1,6 +1,6 @@
// Must be build-pass, because check-pass will not run const prop and thus not emit the lint anyway. // Must be build-pass, because check-pass will not run const prop and thus not emit the lint anyway.
// build-pass // build-pass
// compile-flags: -Zmir-opt-level=2 // compile-flags: -Zmir-opt-level=3
#![deny(warnings)] #![deny(warnings)]

View file

@ -1,8 +1,8 @@
// run-pass // run-pass
// compile-flags: -Z mir-opt-level=3 // compile-flags: -Z mir-opt-level=4
// Checks that the compiler does not ICE when passing references to field of by-value struct // Checks that the compiler does not ICE when passing references to field of by-value struct
// with -Z mir-opt-level=3 // with -Z mir-opt-level=4
fn do_nothing(_: &()) {} fn do_nothing(_: &()) {}

View file

@ -1,4 +1,4 @@
// compile-flags: -Z mir-opt-level=2 // compile-flags: -Z mir-opt-level=3
// run-pass // run-pass
struct Baz<T: ?Sized> { struct Baz<T: ?Sized> {

View file

@ -1,4 +1,4 @@
// compile-flags: -Z mir-opt-level=3 // compile-flags: -Z mir-opt-level=4
// run-pass // run-pass
struct X { struct X {

View file

@ -1,4 +1,4 @@
// compile-flags: -Z mir-opt-level=2 // compile-flags: -Z mir-opt-level=3
// run-pass // run-pass
use std::cell::Cell; use std::cell::Cell;

View file

@ -1,4 +1,4 @@
// compile-flags: -Z mir-opt-level=2 // compile-flags: -Z mir-opt-level=3
// run-pass // run-pass
fn e220() -> (i64, i64) { fn e220() -> (i64, i64) {

View file

@ -1,5 +1,5 @@
// ignore-wasm32-bare which doesn't support `std::process:exit()` // ignore-wasm32-bare which doesn't support `std::process:exit()`
// compile-flags: -Zmir-opt-level=2 // compile-flags: -Zmir-opt-level=3
// run-pass // run-pass
// Tests that specialization does not cause optimizations running on polymorphic MIR to resolve // Tests that specialization does not cause optimizations running on polymorphic MIR to resolve

View file

@ -1,6 +1,6 @@
// run-pass // run-pass
// compile-flags: -Zmir-opt-level=2 // compile-flags: -Zmir-opt-level=3
trait IterExt: Iterator { trait IterExt: Iterator {
fn fold_ex<B, F>(mut self, init: B, mut f: F) -> B fn fold_ex<B, F>(mut self, init: B, mut f: F) -> B

View file

@ -3,7 +3,7 @@
// elaborate-drops invoked on it) and then try to elaboate drops a // elaborate-drops invoked on it) and then try to elaboate drops a
// second time. Uncool. // second time. Uncool.
// compile-flags:-Zmir-opt-level=3 // compile-flags:-Zmir-opt-level=4
// build-pass // build-pass
fn main() { fn main() {

View file

@ -1,5 +1,5 @@
// revisions: default miropt // revisions: default miropt
//[miropt]compile-flags: -Z mir-opt-level=2 //[miropt]compile-flags: -Z mir-opt-level=3
// ~^ This flag is for #77668, it used to be ICE. // ~^ This flag is for #77668, it used to be ICE.
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,4 +1,4 @@
// compile-flags: -Zmir-opt-level=2 -Copt-level=0 // compile-flags: -Zmir-opt-level=3 -Copt-level=0
// run-pass // run-pass
type M = [i64; 2]; type M = [i64; 2];

View file

@ -1,5 +1,5 @@
// edition:2018 // edition:2018
// compile-flags: -Z mir-opt-level=2 // compile-flags: -Z mir-opt-level=3
#[inline(always)] #[inline(always)]
pub fn copy_prop(s: bool) -> String { pub fn copy_prop(s: bool) -> String {

View file

@ -2,7 +2,7 @@
// did not check that the types matched up in the `Ok(r)` branch. // did not check that the types matched up in the `Ok(r)` branch.
// //
// run-pass // run-pass
// compile-flags: -Zmir-opt-level=2 // compile-flags: -Zmir-opt-level=3
#[derive(Debug, PartialEq, Eq)] #[derive(Debug, PartialEq, Eq)]
enum SpecialsRes { Res(u64) } enum SpecialsRes { Res(u64) }

View file

@ -1,4 +1,4 @@
// compile-flags: -Z mir-opt-level=3 // compile-flags: -Z mir-opt-level=4
// build-pass // build-pass
// This used to ICE in const-prop due // This used to ICE in const-prop due

View file

@ -1,4 +1,4 @@
// compile-flags: -Z mir-opt-level=2 // compile-flags: -Z mir-opt-level=3
// build-pass // build-pass
// This used to ICE due to the inling pass not examining projections // This used to ICE due to the inling pass not examining projections

View file

@ -1,4 +1,4 @@
// compile-flags: -Z mir-opt-level=2 // compile-flags: -Z mir-opt-level=3
// edition:2018 // edition:2018
// build-pass // build-pass

View file

@ -4,7 +4,7 @@
// //
// check-pass // check-pass
// edition:2018 // edition:2018
// compile-args: -Zmir-opt-level=2 // compile-args: -Zmir-opt-level=3
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,4 +1,4 @@
// compile-flags: -Z mir-opt-level=2 // compile-flags: -Z mir-opt-level=3
// build-pass // build-pass
#![feature(type_alias_impl_trait)] #![feature(type_alias_impl_trait)]

View file

@ -3,7 +3,7 @@
// Regression test for #76248. // Regression test for #76248.
// //
// build-pass // build-pass
// compile-flags: -Zmir-opt-level=2 // compile-flags: -Zmir-opt-level=3
const N: usize = 1; const N: usize = 1;

View file

@ -2,7 +2,7 @@
// //
// edition:2018 // edition:2018
// build-pass // build-pass
// compile-flags: -Z mir-opt-level=2 // compile-flags: -Z mir-opt-level=3
// aux-build:issue_76375_aux.rs // aux-build:issue_76375_aux.rs
#![crate_type = "lib"] #![crate_type = "lib"]

View file

@ -1,6 +1,6 @@
// Regression test for issue #76740. // Regression test for issue #76740.
// run-pass // run-pass
// compile-flags: -Zmir-opt-level=3 // compile-flags: -Zmir-opt-level=4
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub struct V([usize; 4]); pub struct V([usize; 4]);

View file

@ -1,4 +1,4 @@
// compile-flags: -Z mir-opt-level=2 // compile-flags: -Z mir-opt-level=3
// build-pass // build-pass
use std::fs::File; use std::fs::File;

View file

@ -1,5 +1,5 @@
// run-pass // run-pass
// compile-flags: -Z mir-opt-level=2 -C opt-level=0 // compile-flags: -Z mir-opt-level=3 -C opt-level=0
// example from #78496 // example from #78496
pub enum E<'a> { pub enum E<'a> {

View file

@ -1,4 +1,4 @@
// compile-flags: -Z mir-opt-level=2 // compile-flags: -Z mir-opt-level=3
// build-pass // build-pass
// This used to ICE in const-prop // This used to ICE in const-prop

View file

@ -2,7 +2,7 @@
// Regression test for issue #79269. // Regression test for issue #79269.
// //
// build-pass // build-pass
// compile-flags: -Zmir-opt-level=2 -Zvalidate-mir // compile-flags: -Zmir-opt-level=3 -Zvalidate-mir
#[derive(Clone)] #[derive(Clone)]
struct Array<T, const N: usize>([T; N]); struct Array<T, const N: usize>([T; N]);

View file

@ -1,5 +1,5 @@
// run-pass // run-pass
// compile-flags:-Zmir-opt-level=2 // compile-flags:-Zmir-opt-level=3
trait Array { trait Array {
type Item; type Item;

View file

@ -1,5 +1,5 @@
// run-pass // run-pass
// compile-flags:-Zmir-opt-level=2 // compile-flags:-Zmir-opt-level=3
pub enum Enum { pub enum Enum {
A, A,

View file

@ -1,5 +1,5 @@
// run-pass // run-pass
// compile-flags:-Zmir-opt-level=2 // compile-flags:-Zmir-opt-level=3
pub fn main() { pub fn main() {
let _x: fn() = handle_debug_column; let _x: fn() = handle_debug_column;
} }

View file

@ -1,5 +1,5 @@
// run-pass // run-pass
// compile-flags:-Zmir-opt-level=2 // compile-flags:-Zmir-opt-level=3
// Previously ICEd because we did not normalize during inlining, // Previously ICEd because we did not normalize during inlining,
// see https://github.com/rust-lang/rust/pull/77306 for more discussion. // see https://github.com/rust-lang/rust/pull/77306 for more discussion.

View file

@ -1,5 +1,5 @@
// run-pass // run-pass
// compile-flags:-Zmir-opt-level=2 // compile-flags:-Zmir-opt-level=3
struct Cursor {} struct Cursor {}
struct TokenTree {} struct TokenTree {}

View file

@ -1,5 +1,5 @@
// run-pass // run-pass
// compile-flags:-Zmir-opt-level=2 // compile-flags:-Zmir-opt-level=3
use std::mem::MaybeUninit; use std::mem::MaybeUninit;
const N: usize = 2; const N: usize = 2;

View file

@ -1,9 +1,9 @@
// Ensures -Zmir-opt-level=2 (specifically, inlining) is not allowed with -Zinstrument-coverage. // Ensures -Zmir-opt-level=3 (specifically, inlining) is not allowed with -Zinstrument-coverage.
// Regression test for issue #80060. // Regression test for issue #80060.
// //
// needs-profiler-support // needs-profiler-support
// build-pass // build-pass
// compile-flags: -Zmir-opt-level=2 -Zinstrument-coverage // compile-flags: -Zmir-opt-level=3 -Zinstrument-coverage
#[inline(never)] #[inline(never)]
fn foo() {} fn foo() {}

View file

@ -1,2 +1,2 @@
warning: `-Z mir-opt-level=2` (or any level > 1) enables function inlining, which is incompatible with `-Z instrument-coverage`. Inlining will be disabled. warning: `-Z mir-opt-level=3` (or any level > 1) enables function inlining, which is incompatible with `-Z instrument-coverage`. Inlining will be disabled.

View file

@ -1,5 +1,5 @@
// run-pass // run-pass
// compile-flags:-Zmir-opt-level=2 // compile-flags:-Zmir-opt-level=3
pub trait Foo { pub trait Foo {
fn bar(&self) -> usize { 2 } fn bar(&self) -> usize { 2 }
} }

View file

@ -1,5 +1,5 @@
// run-pass // run-pass
// compile-flags: -Z mir-opt-level=2 -C opt-level=0 -C debuginfo=2 // compile-flags: -Z mir-opt-level=3 -C opt-level=0 -C debuginfo=2
#[inline(never)] #[inline(never)]
pub fn foo(bar: usize) -> usize { pub fn foo(bar: usize) -> usize {

View file

@ -1,4 +1,4 @@
// compile-flags: -Z mir-opt-level=2 // compile-flags: -Z mir-opt-level=3
// build-pass // build-pass
#![crate_type="lib"] #![crate_type="lib"]

View file

@ -1,5 +1,5 @@
// build-pass // build-pass
// compile-flags: -Z mir-opt-level=3 // compile-flags: -Z mir-opt-level=4
#![crate_type="lib"] #![crate_type="lib"]
#![feature(lang_items)] #![feature(lang_items)]

View file

@ -1,5 +1,5 @@
// run-pass // run-pass
// compile-flags: -Zpolymorphize=on -Zmir-opt-level=3 // compile-flags: -Zpolymorphize=on -Zmir-opt-level=4
fn caller<T, U>() -> &'static usize { fn caller<T, U>() -> &'static usize {
callee::<U>() callee::<U>()

View file

@ -1,6 +1,6 @@
// run-pass // run-pass
// revisions: default mir-opt // revisions: default mir-opt
//[mir-opt] compile-flags: -Zmir-opt-level=3 //[mir-opt] compile-flags: -Zmir-opt-level=4
#[inline(never)] #[inline(never)]
#[track_caller] #[track_caller]

View file

@ -1,6 +1,6 @@
// run-pass // run-pass
// revisions: default mir-opt // revisions: default mir-opt
//[mir-opt] compile-flags: -Zmir-opt-level=3 //[mir-opt] compile-flags: -Zmir-opt-level=4
#![feature(const_caller_location, const_fn)] #![feature(const_caller_location, const_fn)]

View file

@ -1,6 +1,6 @@
// run-pass // run-pass
// revisions: default mir-opt // revisions: default mir-opt
//[mir-opt] compile-flags: -Zmir-opt-level=3 //[mir-opt] compile-flags: -Zmir-opt-level=4
macro_rules! caller_location_from_macro { macro_rules! caller_location_from_macro {
() => (core::panic::Location::caller()); () => (core::panic::Location::caller());

View file

@ -1,6 +1,6 @@
// run-pass // run-pass
// revisions: default mir-opt // revisions: default mir-opt
//[mir-opt] compile-flags: -Zmir-opt-level=3 //[mir-opt] compile-flags: -Zmir-opt-level=4
#[track_caller] #[track_caller]
fn f() {} fn f() {}

View file

@ -1,7 +1,7 @@
// run-pass // run-pass
// ignore-wasm32-bare compiled with panic=abort by default // ignore-wasm32-bare compiled with panic=abort by default
// revisions: default mir-opt // revisions: default mir-opt
//[mir-opt] compile-flags: -Zmir-opt-level=3 //[mir-opt] compile-flags: -Zmir-opt-level=4
#![feature(option_expect_none, option_unwrap_none)] #![feature(option_expect_none, option_unwrap_none)]
#![allow(unconditional_panic)] #![allow(unconditional_panic)]

View file

@ -1,6 +1,6 @@
// run-pass // run-pass
// revisions: default mir-opt // revisions: default mir-opt
//[mir-opt] compile-flags: -Zmir-opt-level=3 //[mir-opt] compile-flags: -Zmir-opt-level=4
use std::panic::Location; use std::panic::Location;

View file

@ -1,6 +1,6 @@
// run-pass // run-pass
// revisions: default mir-opt // revisions: default mir-opt
//[mir-opt] compile-flags: -Zmir-opt-level=3 //[mir-opt] compile-flags: -Zmir-opt-level=4
fn pass_to_ptr_call<T>(f: fn(T), x: T) { fn pass_to_ptr_call<T>(f: fn(T), x: T) {
f(x); f(x);

View file

@ -1,6 +1,6 @@
// run-pass // run-pass
// revisions: default mir-opt // revisions: default mir-opt
//[mir-opt] compile-flags: -Zmir-opt-level=3 //[mir-opt] compile-flags: -Zmir-opt-level=4
fn ptr_call(f: fn()) { fn ptr_call(f: fn()) {
f(); f();

View file

@ -2,7 +2,7 @@
// passed the wrong Instance, causing issues with inlining. See #67557. // passed the wrong Instance, causing issues with inlining. See #67557.
// //
// run-pass // run-pass
// compile-flags: -Zmir-opt-level=3 // compile-flags: -Zmir-opt-level=4
#![feature(platform_intrinsics, repr_simd)] #![feature(platform_intrinsics, repr_simd)]
extern "platform-intrinsic" { extern "platform-intrinsic" {

View file

@ -2,7 +2,7 @@
// the wrong Instance, causing issues with inlining. See #67557. // the wrong Instance, causing issues with inlining. See #67557.
// //
// run-pass // run-pass
// compile-flags: -Zmir-opt-level=3 // compile-flags: -Zmir-opt-level=4
#![feature(platform_intrinsics, repr_simd)] #![feature(platform_intrinsics, repr_simd)]
extern "platform-intrinsic" { extern "platform-intrinsic" {

View file

@ -83,7 +83,7 @@ impl rustc_driver::Callbacks for ClippyCallbacks {
// run on the unoptimized MIR. On the other hand this results in some false negatives. If // run on the unoptimized MIR. On the other hand this results in some false negatives. If
// MIR passes can be enabled / disabled separately, we should figure out, what passes to // MIR passes can be enabled / disabled separately, we should figure out, what passes to
// use for Clippy. // use for Clippy.
config.opts.debugging_opts.mir_opt_level = 0; config.opts.debugging_opts.mir_opt_level = Some(0);
} }
} }

View file

@ -1960,7 +1960,7 @@ impl<'test> TestCx<'test> {
rustc.args(&[ rustc.args(&[
"-Copt-level=1", "-Copt-level=1",
"-Zdump-mir=all", "-Zdump-mir=all",
"-Zmir-opt-level=3", "-Zmir-opt-level=4",
"-Zvalidate-mir", "-Zvalidate-mir",
"-Zdump-mir-exclude-pass-number", "-Zdump-mir-exclude-pass-number",
]); ]);