Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable destination propagation on all mir-opt-levels #82684

Merged
merged 1 commit into from
Mar 8, 2021
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
5 changes: 5 additions & 0 deletions compiler/rustc_mir/src/transform/dest_prop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ pub struct DestinationPropagation;

impl<'tcx> MirPass<'tcx> for DestinationPropagation {
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
// FIXME(#79191, #82678)
if !tcx.sess.opts.debugging_opts.unsound_mir_opts {
return;
}

// Only run at mir-opt-level=3 or higher for now (we don't fix up debuginfo and remove
// storage statements at the moment).
if tcx.sess.mir_opt_level() < 3 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,26 @@
debug s => _1; // in scope 0 at $DIR/deduplicate_blocks.rs:2:36: 2:37
let mut _0: bool; // return place in scope 0 at $DIR/deduplicate_blocks.rs:2:48: 2:52
let mut _2: &[u8]; // in scope 0 at $DIR/deduplicate_blocks.rs:3:11: 3:23
let mut _3: usize; // in scope 0 at $DIR/deduplicate_blocks.rs:5:9: 5:31
let mut _4: bool; // in scope 0 at $DIR/deduplicate_blocks.rs:5:9: 5:31
let mut _5: usize; // in scope 0 at $DIR/deduplicate_blocks.rs:4:9: 4:37
let mut _6: bool; // in scope 0 at $DIR/deduplicate_blocks.rs:4:9: 4:37
let mut _3: &str; // in scope 0 at $DIR/deduplicate_blocks.rs:3:11: 3:12
let mut _4: usize; // in scope 0 at $DIR/deduplicate_blocks.rs:5:9: 5:31
let mut _5: bool; // in scope 0 at $DIR/deduplicate_blocks.rs:5:9: 5:31
let mut _6: usize; // in scope 0 at $DIR/deduplicate_blocks.rs:4:9: 4:37
let mut _7: bool; // in scope 0 at $DIR/deduplicate_blocks.rs:4:9: 4:37
scope 1 (inlined core::str::<impl str>::as_bytes) { // at $DIR/deduplicate_blocks.rs:3:11: 3:23
debug self => _7; // in scope 1 at $DIR/deduplicate_blocks.rs:3:11: 3:23
let mut _7: &str; // in scope 1 at $DIR/deduplicate_blocks.rs:3:11: 3:23
debug self => _3; // in scope 1 at $DIR/deduplicate_blocks.rs:3:11: 3:23
let mut _8: &str; // in scope 1 at $DIR/deduplicate_blocks.rs:3:11: 3:23
scope 2 {
}
}

bb0: {
StorageLive(_2); // scope 0 at $DIR/deduplicate_blocks.rs:3:11: 3:23
_7 = _1; // scope 0 at $DIR/deduplicate_blocks.rs:3:11: 3:12
- _2 = transmute::<&str, &[u8]>(move _7) -> bb14; // scope 2 at $DIR/deduplicate_blocks.rs:3:11: 3:23
+ _2 = transmute::<&str, &[u8]>(move _7) -> bb12; // scope 2 at $DIR/deduplicate_blocks.rs:3:11: 3:23
StorageLive(_3); // scope 0 at $DIR/deduplicate_blocks.rs:3:11: 3:12
_3 = _1; // scope 0 at $DIR/deduplicate_blocks.rs:3:11: 3:12
StorageLive(_8); // scope 2 at $DIR/deduplicate_blocks.rs:3:11: 3:23
_8 = _3; // scope 2 at $DIR/deduplicate_blocks.rs:3:11: 3:23
- _2 = transmute::<&str, &[u8]>(move _8) -> bb14; // scope 2 at $DIR/deduplicate_blocks.rs:3:11: 3:23
+ _2 = transmute::<&str, &[u8]>(move _8) -> bb12; // scope 2 at $DIR/deduplicate_blocks.rs:3:11: 3:23
// mir::Constant
// + span: $DIR/deduplicate_blocks.rs:3:11: 3:23
// + literal: Const { ty: unsafe extern "rust-intrinsic" fn(&str) -> &[u8] {std::intrinsics::transmute::<&str, &[u8]>}, val: Value(Scalar(<ZST>)) }
Expand All @@ -44,9 +48,9 @@
}

bb5: {
_3 = Len((*_2)); // scope 0 at $DIR/deduplicate_blocks.rs:5:9: 5:31
_4 = Ge(move _3, const 3_usize); // scope 0 at $DIR/deduplicate_blocks.rs:5:9: 5:31
switchInt(move _4) -> [false: bb9, otherwise: bb6]; // scope 0 at $DIR/deduplicate_blocks.rs:5:9: 5:31
_4 = Len((*_2)); // scope 0 at $DIR/deduplicate_blocks.rs:5:9: 5:31
_5 = Ge(move _4, const 3_usize); // scope 0 at $DIR/deduplicate_blocks.rs:5:9: 5:31
switchInt(move _5) -> [false: bb9, otherwise: bb6]; // scope 0 at $DIR/deduplicate_blocks.rs:5:9: 5:31
}

bb6: {
Expand Down Expand Up @@ -93,9 +97,11 @@

- bb14: {
+ bb12: {
_5 = Len((*_2)); // scope 0 at $DIR/deduplicate_blocks.rs:4:9: 4:37
_6 = Ge(move _5, const 4_usize); // scope 0 at $DIR/deduplicate_blocks.rs:4:9: 4:37
switchInt(move _6) -> [false: bb5, otherwise: bb1]; // scope 0 at $DIR/deduplicate_blocks.rs:4:9: 4:37
StorageDead(_8); // scope 2 at $DIR/deduplicate_blocks.rs:3:11: 3:23
StorageDead(_3); // scope 0 at $DIR/deduplicate_blocks.rs:3:22: 3:23
_6 = Len((*_2)); // scope 0 at $DIR/deduplicate_blocks.rs:4:9: 4:37
_7 = Ge(move _6, const 4_usize); // scope 0 at $DIR/deduplicate_blocks.rs:4:9: 4:37
switchInt(move _7) -> [false: bb5, otherwise: bb1]; // scope 0 at $DIR/deduplicate_blocks.rs:4:9: 4:37
}
}

2 changes: 1 addition & 1 deletion src/test/mir-opt/dest-prop/branch.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Tests that assignment in both branches of an `if` are eliminated.

// compile-flags: -Zunsound-mir-opts
fn val() -> i32 {
1
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/mir-opt/dest-prop/copy_propagation_arg.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Check that DestinationPropagation does not propagate an assignment to a function argument
// (doing so can break usages of the original argument value)

// compile-flags: -Zunsound-mir-opts
fn dummy(x: u8) -> u8 {
x
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/mir-opt/dest-prop/cycle.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Tests that cyclic assignments don't hang DestinationPropagation, and result in reasonable code.

// compile-flags: -Zunsound-mir-opts
fn val() -> i32 {
1
}
Expand Down
2 changes: 1 addition & 1 deletion src/test/mir-opt/dest-prop/simple.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Copy of `nrvo-simple.rs`, to ensure that full dest-prop handles it too.

// compile-flags: -Zunsound-mir-opts
// EMIT_MIR simple.nrvo.DestinationPropagation.diff
fn nrvo(init: fn(&mut [u8; 1024])) -> [u8; 1024] {
let mut buf = [0; 1024];
Expand Down
2 changes: 1 addition & 1 deletion src/test/mir-opt/dest-prop/union.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Tests that projections through unions cancel `DestinationPropagation`.

// compile-flags: -Zunsound-mir-opts
fn val() -> u32 {
1
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ fn foo(_1: T, _2: i32) -> (i32, T) {
debug _q => _9; // in scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9
debug q => (*((*_6).0: &i32)); // in scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9
debug t => (*((*_6).1: &T)); // in scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9
let mut _10: T; // in scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9
let mut _10: i32; // in scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9
let mut _11: T; // in scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9
}
}

Expand All @@ -39,10 +40,13 @@ fn foo(_1: T, _2: i32) -> (i32, T) {
(_7.0: i32) = move _8; // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9
StorageLive(_9); // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9
_9 = move (_7.0: i32); // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9
(_0.0: i32) = (*((*_6).0: &i32)); // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9
StorageLive(_10); // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9
_10 = (*((*_6).1: &T)); // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9
(_0.1: T) = move _10; // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9
_10 = (*((*_6).0: &i32)); // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9
StorageLive(_11); // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9
_11 = (*((*_6).1: &T)); // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9
(_0.0: i32) = move _10; // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9
(_0.1: T) = move _11; // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9
StorageDead(_11); // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9
StorageDead(_10); // scope 2 at $DIR/inline-closure-captures.rs:12:5: 12:9
StorageDead(_9); // scope 1 at $DIR/inline-closure-captures.rs:12:5: 12:9
StorageDead(_8); // scope 1 at $DIR/inline-closure-captures.rs:12:8: 12:9
Expand Down
17 changes: 9 additions & 8 deletions src/test/mir-opt/inline/inline_diverging.h.Inline.diff
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,20 @@
let mut _0: (); // return place in scope 0 at $DIR/inline-diverging.rs:21:12: 21:12
let _1: (!, !); // in scope 0 at $DIR/inline-diverging.rs:22:5: 22:22
+ let mut _2: fn() -> ! {sleep}; // in scope 0 at $DIR/inline-diverging.rs:22:5: 22:22
+ let mut _7: (); // in scope 0 at $DIR/inline-diverging.rs:22:5: 22:22
+ let mut _8: (); // in scope 0 at $DIR/inline-diverging.rs:22:5: 22:22
+ let mut _9: (); // in scope 0 at $DIR/inline-diverging.rs:22:5: 22:22
+ let mut _10: (); // in scope 0 at $DIR/inline-diverging.rs:22:5: 22:22
+ scope 1 (inlined call_twice::<!, fn() -> ! {sleep}>) { // at $DIR/inline-diverging.rs:22:5: 22:22
+ debug f => _2; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22
+ let _3: !; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22
+ let mut _4: &fn() -> ! {sleep}; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22
+ let mut _5: &fn() -> ! {sleep}; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22
+ let mut _6: !; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22
+ let mut _6: &fn() -> ! {sleep}; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22
+ let mut _7: !; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22
+ let mut _8: !; // in scope 1 at $DIR/inline-diverging.rs:22:5: 22:22
+ scope 2 {
+ debug a => _3; // in scope 2 at $DIR/inline-diverging.rs:22:5: 22:22
+ let _5: !; // in scope 2 at $DIR/inline-diverging.rs:22:5: 22:22
+ scope 3 {
+ debug b => _6; // in scope 3 at $DIR/inline-diverging.rs:22:5: 22:22
+ debug b => _5; // in scope 3 at $DIR/inline-diverging.rs:22:5: 22:22
+ }
+ scope 6 (inlined <fn() -> ! {sleep} as Fn<()>>::call - shim(fn() -> ! {sleep})) { // at $DIR/inline-diverging.rs:22:5: 22:22
+ scope 7 (inlined sleep) { // at $DIR/inline-diverging.rs:22:5: 22:22
Expand All @@ -40,12 +42,11 @@
- // mir::Constant
// + span: $DIR/inline-diverging.rs:22:16: 22:21
// + literal: Const { ty: fn() -> ! {sleep}, val: Value(Scalar(<ZST>)) }
+ StorageLive(_6); // scope 0 at $DIR/inline-diverging.rs:22:5: 22:22
+ StorageLive(_3); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22
+ StorageLive(_4); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22
+ _4 = &_2; // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22
+ StorageLive(_7); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22
+ _7 = const (); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22
+ StorageLive(_9); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22
+ _9 = const (); // scope 1 at $DIR/inline-diverging.rs:22:5: 22:22
+ goto -> bb1; // scope 4 at $DIR/inline-diverging.rs:22:5: 22:22
}

Expand Down
41 changes: 27 additions & 14 deletions src/test/mir-opt/inline/inline_generator.main.Inline.diff
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,12 @@
+ }
+ }
+ scope 6 (inlined g::{closure#0}) { // at $DIR/inline-generator.rs:9:14: 9:46
+ debug a => _8; // in scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ let mut _8: bool; // in scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ let mut _9: u32; // in scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ debug a => _11; // in scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ let mut _8: i32; // in scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ let mut _9: bool; // in scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ let mut _10: bool; // in scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ let _11: bool; // in scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ let mut _12: u32; // in scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ }

bb0: {
Expand Down Expand Up @@ -65,16 +68,18 @@
- // + literal: Const { ty: for<'r> fn(std::pin::Pin<&'r mut impl std::ops::Generator<bool>>, bool) -> std::ops::GeneratorState<<impl std::ops::Generator<bool> as std::ops::Generator<bool>>::Yield, <impl std::ops::Generator<bool> as std::ops::Generator<bool>>::Return> {<impl std::ops::Generator<bool> as std::ops::Generator<bool>>::resume}, val: Value(Scalar(<ZST>)) }
+ StorageLive(_7); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
+ _7 = const false; // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
+ StorageLive(_8); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
+ StorageLive(_9); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
+ _9 = discriminant((*(_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41 {bool, i32}]))); // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ switchInt(move _9) -> [0_u32: bb3, 1_u32: bb8, 3_u32: bb7, otherwise: bb9]; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ StorageLive(_10); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
+ StorageLive(_11); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
+ StorageLive(_12); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
+ _12 = discriminant((*(_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41 {bool, i32}]))); // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ switchInt(move _12) -> [0_u32: bb3, 1_u32: bb8, 3_u32: bb7, otherwise: bb9]; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
}

- bb3: {
+ bb1: {
+ StorageDead(_9); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
+ StorageDead(_8); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
+ StorageDead(_12); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
+ StorageDead(_11); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
+ StorageDead(_10); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
+ StorageDead(_7); // scope 0 at $DIR/inline-generator.rs:9:14: 9:46
StorageDead(_2); // scope 0 at $DIR/inline-generator.rs:9:45: 9:46
StorageDead(_4); // scope 0 at $DIR/inline-generator.rs:9:46: 9:47
Expand All @@ -89,28 +94,36 @@
+ }
+
+ bb3: {
+ _8 = move _7; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ switchInt(move _8) -> [false: bb5, otherwise: bb4]; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ _11 = move _7; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ StorageLive(_8); // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ StorageLive(_9); // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ _9 = _11; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ switchInt(move _9) -> [false: bb5, otherwise: bb4]; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ }
+
+ bb4: {
+ ((_1 as Yielded).0: i32) = const 7_i32; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ _8 = const 7_i32; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ goto -> bb6; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ }
+
+ bb5: {
+ ((_1 as Yielded).0: i32) = const 13_i32; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ _8 = const 13_i32; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ goto -> bb6; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ }
+
+ bb6: {
+ StorageDead(_9); // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ ((_1 as Yielded).0: i32) = move _8; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ discriminant(_1) = 0; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ discriminant((*(_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41 {bool, i32}]))) = 3; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ goto -> bb1; // scope 0 at $DIR/inline-generator.rs:15:11: 15:39
+ }
+
+ bb7: {
+ ((_1 as Complete).0: bool) = move _7; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ StorageLive(_8); // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ _10 = move _7; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ StorageDead(_8); // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ ((_1 as Complete).0: bool) = move _10; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ discriminant(_1) = 1; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ discriminant((*(_2.0: &mut [generator@$DIR/inline-generator.rs:15:5: 15:41 {bool, i32}]))) = 1; // scope 6 at $DIR/inline-generator.rs:9:14: 9:46
+ goto -> bb1; // scope 0 at $DIR/inline-generator.rs:15:41: 15:41
Expand Down
Loading