forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#108208 - cjgillot:flood-enum, r=oli-obk
Correctly handle aggregates in DataflowConstProp The previous implementation from rust-lang#107411 flooded target of an aggregate assignment with `Bottom`, corresponding to the `deinit` that the interpreter does. As a consequence, when assigning `target = Enum::Variant#i(...)` all the `(target as Variant#j)` were at `Bottom` while they should have been `Top`. This PR replaces that flooding with `Top`. Aside, it corrects a second bug where the wrong place would be used to assign to enum variant fields, resulting to nothing happening. Fixes rust-lang#108166
- Loading branch information
Showing
4 changed files
with
120 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
tests/mir-opt/dataflow-const-prop/enum.multiple.DataflowConstProp.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
- // MIR for `multiple` before DataflowConstProp | ||
+ // MIR for `multiple` after DataflowConstProp | ||
|
||
fn multiple(_1: bool, _2: u8) -> () { | ||
debug x => _1; // in scope 0 at $DIR/enum.rs:+0:13: +0:14 | ||
debug i => _2; // in scope 0 at $DIR/enum.rs:+0:22: +0:23 | ||
let mut _0: (); // return place in scope 0 at $DIR/enum.rs:+0:29: +0:29 | ||
let _3: std::option::Option<u8>; // in scope 0 at $DIR/enum.rs:+1:9: +1:10 | ||
let mut _4: bool; // in scope 0 at $DIR/enum.rs:+1:16: +1:17 | ||
let mut _5: u8; // in scope 0 at $DIR/enum.rs:+2:14: +2:15 | ||
let mut _7: isize; // in scope 0 at $DIR/enum.rs:+9:23: +9:30 | ||
scope 1 { | ||
debug e => _3; // in scope 1 at $DIR/enum.rs:+1:9: +1:10 | ||
let _6: u8; // in scope 1 at $DIR/enum.rs:+9:9: +9:10 | ||
let _8: u8; // in scope 1 at $DIR/enum.rs:+9:28: +9:29 | ||
scope 2 { | ||
debug x => _6; // in scope 2 at $DIR/enum.rs:+9:9: +9:10 | ||
let _9: u8; // in scope 2 at $DIR/enum.rs:+11:9: +11:10 | ||
scope 4 { | ||
debug y => _9; // in scope 4 at $DIR/enum.rs:+11:9: +11:10 | ||
} | ||
} | ||
scope 3 { | ||
debug i => _8; // in scope 3 at $DIR/enum.rs:+9:28: +9:29 | ||
} | ||
} | ||
|
||
bb0: { | ||
StorageLive(_3); // scope 0 at $DIR/enum.rs:+1:9: +1:10 | ||
StorageLive(_4); // scope 0 at $DIR/enum.rs:+1:16: +1:17 | ||
_4 = _1; // scope 0 at $DIR/enum.rs:+1:16: +1:17 | ||
switchInt(move _4) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/enum.rs:+1:16: +1:17 | ||
} | ||
|
||
bb1: { | ||
StorageLive(_5); // scope 0 at $DIR/enum.rs:+2:14: +2:15 | ||
_5 = _2; // scope 0 at $DIR/enum.rs:+2:14: +2:15 | ||
_3 = Option::<u8>::Some(move _5); // scope 0 at $DIR/enum.rs:+2:9: +2:16 | ||
StorageDead(_5); // scope 0 at $DIR/enum.rs:+2:15: +2:16 | ||
goto -> bb3; // scope 0 at $DIR/enum.rs:+1:13: +5:6 | ||
} | ||
|
||
bb2: { | ||
_3 = Option::<u8>::None; // scope 0 at $DIR/enum.rs:+4:9: +4:13 | ||
goto -> bb3; // scope 0 at $DIR/enum.rs:+1:13: +5:6 | ||
} | ||
|
||
bb3: { | ||
StorageDead(_4); // scope 0 at $DIR/enum.rs:+5:5: +5:6 | ||
StorageLive(_6); // scope 1 at $DIR/enum.rs:+9:9: +9:10 | ||
_7 = discriminant(_3); // scope 1 at $DIR/enum.rs:+9:19: +9:20 | ||
switchInt(move _7) -> [0: bb4, 1: bb6, otherwise: bb5]; // scope 1 at $DIR/enum.rs:+9:13: +9:20 | ||
} | ||
|
||
bb4: { | ||
_6 = const 0_u8; // scope 1 at $DIR/enum.rs:+9:45: +9:46 | ||
goto -> bb7; // scope 1 at $DIR/enum.rs:+9:45: +9:46 | ||
} | ||
|
||
bb5: { | ||
unreachable; // scope 1 at $DIR/enum.rs:+9:19: +9:20 | ||
} | ||
|
||
bb6: { | ||
StorageLive(_8); // scope 1 at $DIR/enum.rs:+9:28: +9:29 | ||
_8 = ((_3 as Some).0: u8); // scope 1 at $DIR/enum.rs:+9:28: +9:29 | ||
_6 = _8; // scope 3 at $DIR/enum.rs:+9:34: +9:35 | ||
StorageDead(_8); // scope 1 at $DIR/enum.rs:+9:34: +9:35 | ||
goto -> bb7; // scope 1 at $DIR/enum.rs:+9:34: +9:35 | ||
} | ||
|
||
bb7: { | ||
StorageLive(_9); // scope 2 at $DIR/enum.rs:+11:9: +11:10 | ||
_9 = _6; // scope 2 at $DIR/enum.rs:+11:13: +11:14 | ||
_0 = const (); // scope 0 at $DIR/enum.rs:+0:29: +12:2 | ||
StorageDead(_9); // scope 2 at $DIR/enum.rs:+12:1: +12:2 | ||
StorageDead(_6); // scope 1 at $DIR/enum.rs:+12:1: +12:2 | ||
StorageDead(_3); // scope 0 at $DIR/enum.rs:+12:1: +12:2 | ||
return; // scope 0 at $DIR/enum.rs:+12:2: +12:2 | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters