Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions compiler/rustc_mir_transform/src/dest_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,7 @@ pub(super) struct DestinationPropagation;

impl<'tcx> crate::MirPass<'tcx> for DestinationPropagation {
fn is_enabled(&self, sess: &rustc_session::Session) -> bool {
// For now, only run at MIR opt level 3. Two things need to be changed before this can be
// turned on by default:
// 1. Because of the overeager removal of storage statements, this can cause stack space
// regressions. This opt is not the place to fix this though, it's a more general
// problem in MIR.
// 2. Despite being an overall perf improvement, this still causes a 30% regression in
// keccak. We can temporarily fix this by bounding function size, but in the long term
// we should fix this by being smarter about invalidating analysis results.
sess.mir_opt_level() >= 3
sess.mir_opt_level() >= 2
}

#[tracing::instrument(level = "trace", skip(self, tcx, body))]
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_mir_transform/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ declare_passes! {
mod match_branches : MatchBranchSimplification;
mod mentioned_items : MentionedItems;
mod multiple_return_terminators : MultipleReturnTerminators;
mod nrvo : RenameReturnPlace;
mod post_drop_elaboration : CheckLiveDrops;
mod prettify : ReorderBasicBlocks, ReorderLocals;
mod promote_consts : PromoteTemps;
Expand Down Expand Up @@ -715,15 +714,14 @@ pub(crate) fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'
&jump_threading::JumpThreading,
&early_otherwise_branch::EarlyOtherwiseBranch,
&simplify_comparison_integral::SimplifyComparisonIntegral,
&dest_prop::DestinationPropagation,
&o1(simplify_branches::SimplifyConstCondition::Final),
&o1(remove_noop_landing_pads::RemoveNoopLandingPads),
&o1(simplify::SimplifyCfg::Final),
// After the last SimplifyCfg, because this wants one-block functions.
&strip_debuginfo::StripDebugInfo,
&copy_prop::CopyProp,
&dead_store_elimination::DeadStoreElimination::Final,
&nrvo::RenameReturnPlace,
&dest_prop::DestinationPropagation,
&simplify::SimplifyLocals::Final,
&multiple_return_terminators::MultipleReturnTerminators,
&large_enums::EnumSizeOpt { discrepancy: 128 },
Expand Down
234 changes: 0 additions & 234 deletions compiler/rustc_mir_transform/src/nrvo.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- // MIR for `nrvo` before RenameReturnPlace
+ // MIR for `nrvo` after RenameReturnPlace
- // MIR for `nrvo` before DestinationPropagation
+ // MIR for `nrvo` after DestinationPropagation

fn nrvo(_1: for<'a> fn(&'a mut [u8; 1024])) -> [u8; 1024] {
debug init => _1;
Expand All @@ -10,32 +10,33 @@
let mut _5: &mut [u8; 1024];
let mut _6: &mut [u8; 1024];
scope 1 {
- debug buf => _2;
+ debug buf => _0;
debug buf => _2;
}

bb0: {
- StorageLive(_2);
- _2 = [const 0_u8; 1024];
+ _0 = [const 0_u8; 1024];
StorageLive(_2);
_2 = [const 0_u8; 1024];
StorageLive(_3);
StorageLive(_4);
_4 = copy _1;
- StorageLive(_4);
- _4 = copy _1;
+ nop;
+ nop;
StorageLive(_5);
StorageLive(_6);
- _6 = &mut _2;
+ _6 = &mut _0;
_6 = &mut _2;
_5 = &mut (*_6);
_3 = move _4(move _5) -> [return: bb1, unwind unreachable];
- _3 = move _4(move _5) -> [return: bb1, unwind unreachable];
+ _3 = move _1(move _5) -> [return: bb1, unwind unreachable];
}

bb1: {
StorageDead(_5);
StorageDead(_4);
- StorageDead(_4);
+ nop;
StorageDead(_6);
StorageDead(_3);
- _0 = copy _2;
- StorageDead(_2);
_0 = copy _2;
StorageDead(_2);
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
- // MIR for `nrvo` before RenameReturnPlace
+ // MIR for `nrvo` after RenameReturnPlace
- // MIR for `nrvo` before DestinationPropagation
+ // MIR for `nrvo` after DestinationPropagation

fn nrvo(_1: for<'a> fn(&'a mut [u8; 1024])) -> [u8; 1024] {
debug init => _1;
Expand All @@ -10,32 +10,33 @@
let mut _5: &mut [u8; 1024];
let mut _6: &mut [u8; 1024];
scope 1 {
- debug buf => _2;
+ debug buf => _0;
debug buf => _2;
}

bb0: {
- StorageLive(_2);
- _2 = [const 0_u8; 1024];
+ _0 = [const 0_u8; 1024];
StorageLive(_2);
_2 = [const 0_u8; 1024];
StorageLive(_3);
StorageLive(_4);
_4 = copy _1;
- StorageLive(_4);
- _4 = copy _1;
+ nop;
+ nop;
StorageLive(_5);
StorageLive(_6);
- _6 = &mut _2;
+ _6 = &mut _0;
_6 = &mut _2;
_5 = &mut (*_6);
_3 = move _4(move _5) -> [return: bb1, unwind continue];
- _3 = move _4(move _5) -> [return: bb1, unwind continue];
+ _3 = move _1(move _5) -> [return: bb1, unwind continue];
}

bb1: {
StorageDead(_5);
StorageDead(_4);
- StorageDead(_4);
+ nop;
StorageDead(_6);
StorageDead(_3);
- _0 = copy _2;
- StorageDead(_2);
_0 = copy _2;
StorageDead(_2);
return;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// skip-filecheck
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
//@ test-mir-pass: RenameReturnPlace
//@ test-mir-pass: DestinationPropagation

// EMIT_MIR nrvo_simple.nrvo.RenameReturnPlace.diff
// EMIT_MIR nrvo_borrowed.nrvo.DestinationPropagation.diff
fn nrvo(init: fn(&mut [u8; 1024])) -> [u8; 1024] {
let mut buf = [0; 1024];
init(&mut buf);
Expand Down
Loading
Loading