From 59c243331d60e74290102d5450587adf58597dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mi=C4=85sko?= Date: Sun, 4 Oct 2020 00:00:00 +0000 Subject: [PATCH] Enable RenameReturnPlace MIR optimization on mir-opt-level >= 2 The destination propagation as currently implemented does not supersede the NRVO, e.g., the destination propagation never applies if either local has an address taken, while NRVO might. Additionally, the issue with failing assertions had been already resolved. Continue running both optimizations at mir-opt-level >= 2. --- compiler/rustc_mir/src/transform/nrvo.rs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/compiler/rustc_mir/src/transform/nrvo.rs b/compiler/rustc_mir/src/transform/nrvo.rs index 1ffb5a87c47..3673b6a4aa2 100644 --- a/compiler/rustc_mir/src/transform/nrvo.rs +++ b/compiler/rustc_mir/src/transform/nrvo.rs @@ -36,12 +36,6 @@ impl<'tcx> MirPass<'tcx> for RenameReturnPlace { return; } - if tcx.sess.opts.debugging_opts.mir_opt_level >= 2 { - // The `DestinationPropagation` pass runs at level 2, so this pass is redundant (and - // fails some asserts). - return; - } - let returned_local = match local_eligible_for_nrvo(body) { Some(l) => l, None => {