Skip to content

Commit 63555ae

Browse files
committed
Enable DestinationPropagation by default.
1 parent 1a851da commit 63555ae

21 files changed

+373
-660
lines changed

compiler/rustc_mir_transform/src/dest_prop.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ impl<'tcx> MirPass<'tcx> for DestinationPropagation {
159159
// 2. Despite being an overall perf improvement, this still causes a 30% regression in
160160
// keccak. We can temporarily fix this by bounding function size, but in the long term
161161
// we should fix this by being smarter about invalidating analysis results.
162-
sess.mir_opt_level() >= 3
162+
sess.mir_opt_level() >= 2
163163
}
164164

165165
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {

compiler/rustc_mir_transform/src/lib.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ mod match_branches;
8989
mod mentioned_items;
9090
mod multiple_return_terminators;
9191
mod normalize_array_len;
92-
mod nrvo;
9392
mod prettify;
9493
mod promote_consts;
9594
mod ref_prop;
@@ -599,13 +598,12 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
599598
&jump_threading::JumpThreading,
600599
&early_otherwise_branch::EarlyOtherwiseBranch,
601600
&simplify_comparison_integral::SimplifyComparisonIntegral,
602-
&dest_prop::DestinationPropagation,
603601
&o1(simplify_branches::SimplifyConstCondition::Final),
604602
&o1(remove_noop_landing_pads::RemoveNoopLandingPads),
605603
&o1(simplify::SimplifyCfg::Final),
606604
&copy_prop::CopyProp,
607605
&dead_store_elimination::DeadStoreElimination::Final,
608-
&nrvo::RenameReturnPlace,
606+
&dest_prop::DestinationPropagation,
609607
&simplify::SimplifyLocals::Final,
610608
&multiple_return_terminators::MultipleReturnTerminators,
611609
&deduplicate_blocks::DeduplicateBlocks,

compiler/rustc_mir_transform/src/nrvo.rs

-234
This file was deleted.

tests/mir-opt/nrvo_simple.nrvo.RenameReturnPlace.panic-abort.diff renamed to tests/mir-opt/dest-prop/nrvo_borrowed.nrvo.DestinationPropagation.panic-abort.diff

+16-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
- // MIR for `nrvo` before RenameReturnPlace
2-
+ // MIR for `nrvo` after RenameReturnPlace
1+
- // MIR for `nrvo` before DestinationPropagation
2+
+ // MIR for `nrvo` after DestinationPropagation
33

44
fn nrvo(_1: for<'a> fn(&'a mut [u8; 1024])) -> [u8; 1024] {
55
debug init => _1;
@@ -10,32 +10,33 @@
1010
let mut _5: &mut [u8; 1024];
1111
let mut _6: &mut [u8; 1024];
1212
scope 1 {
13-
- debug buf => _2;
14-
+ debug buf => _0;
13+
debug buf => _2;
1514
}
1615

1716
bb0: {
18-
- StorageLive(_2);
19-
- _2 = [const 0_u8; 1024];
20-
+ _0 = [const 0_u8; 1024];
17+
StorageLive(_2);
18+
_2 = [const 0_u8; 1024];
2119
StorageLive(_3);
22-
StorageLive(_4);
23-
_4 = _1;
20+
- StorageLive(_4);
21+
- _4 = _1;
22+
+ nop;
23+
+ nop;
2424
StorageLive(_5);
2525
StorageLive(_6);
26-
- _6 = &mut _2;
27-
+ _6 = &mut _0;
26+
_6 = &mut _2;
2827
_5 = &mut (*_6);
29-
_3 = move _4(move _5) -> [return: bb1, unwind unreachable];
28+
- _3 = move _4(move _5) -> [return: bb1, unwind unreachable];
29+
+ _3 = move _1(move _5) -> [return: bb1, unwind unreachable];
3030
}
3131

3232
bb1: {
3333
StorageDead(_5);
34-
StorageDead(_4);
34+
- StorageDead(_4);
35+
+ nop;
3536
StorageDead(_6);
3637
StorageDead(_3);
37-
- _0 = _2;
38-
- StorageDead(_2);
38+
_0 = _2;
39+
StorageDead(_2);
3940
return;
4041
}
4142
}

tests/mir-opt/nrvo_simple.nrvo.RenameReturnPlace.panic-unwind.diff renamed to tests/mir-opt/dest-prop/nrvo_borrowed.nrvo.DestinationPropagation.panic-unwind.diff

+16-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
- // MIR for `nrvo` before RenameReturnPlace
2-
+ // MIR for `nrvo` after RenameReturnPlace
1+
- // MIR for `nrvo` before DestinationPropagation
2+
+ // MIR for `nrvo` after DestinationPropagation
33

44
fn nrvo(_1: for<'a> fn(&'a mut [u8; 1024])) -> [u8; 1024] {
55
debug init => _1;
@@ -10,32 +10,33 @@
1010
let mut _5: &mut [u8; 1024];
1111
let mut _6: &mut [u8; 1024];
1212
scope 1 {
13-
- debug buf => _2;
14-
+ debug buf => _0;
13+
debug buf => _2;
1514
}
1615

1716
bb0: {
18-
- StorageLive(_2);
19-
- _2 = [const 0_u8; 1024];
20-
+ _0 = [const 0_u8; 1024];
17+
StorageLive(_2);
18+
_2 = [const 0_u8; 1024];
2119
StorageLive(_3);
22-
StorageLive(_4);
23-
_4 = _1;
20+
- StorageLive(_4);
21+
- _4 = _1;
22+
+ nop;
23+
+ nop;
2424
StorageLive(_5);
2525
StorageLive(_6);
26-
- _6 = &mut _2;
27-
+ _6 = &mut _0;
26+
_6 = &mut _2;
2827
_5 = &mut (*_6);
29-
_3 = move _4(move _5) -> [return: bb1, unwind continue];
28+
- _3 = move _4(move _5) -> [return: bb1, unwind continue];
29+
+ _3 = move _1(move _5) -> [return: bb1, unwind continue];
3030
}
3131

3232
bb1: {
3333
StorageDead(_5);
34-
StorageDead(_4);
34+
- StorageDead(_4);
35+
+ nop;
3536
StorageDead(_6);
3637
StorageDead(_3);
37-
- _0 = _2;
38-
- StorageDead(_2);
38+
_0 = _2;
39+
StorageDead(_2);
3940
return;
4041
}
4142
}

tests/mir-opt/nrvo_simple.rs renamed to tests/mir-opt/dest-prop/nrvo_borrowed.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
// skip-filecheck
22
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
3-
//@ test-mir-pass: RenameReturnPlace
3+
//@ test-mir-pass: DestinationPropagation
44

5-
// EMIT_MIR nrvo_simple.nrvo.RenameReturnPlace.diff
5+
// EMIT_MIR nrvo_borrowed.nrvo.DestinationPropagation.diff
66
fn nrvo(init: fn(&mut [u8; 1024])) -> [u8; 1024] {
77
let mut buf = [0; 1024];
88
init(&mut buf);

0 commit comments

Comments
 (0)