Skip to content

Commit

Permalink
Rollup merge of #77525 - tmiasko:nrvo-2, r=jonas-schievink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jonas-schievink authored Oct 4, 2020
2 parents 5889cf3 + 59c2433 commit fa200ce
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions compiler/rustc_mir/src/transform/nrvo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down

0 comments on commit fa200ce

Please sign in to comment.