forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of rust-lang#105229 - saethlin:zst-writes-to-unions, r=oli…
…-obk Re-enable removal of ZST writes to unions This was previously disabled because Miri was lazily allocating unsized locals. But we aren't doing that anymore since rust-lang#98831, so we can have this optimization back.
- Loading branch information
Showing
6 changed files
with
44 additions
and
60 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
10 changes: 10 additions & 0 deletions
10
src/test/mir-opt/remove_zsts.get_union.PreCodegen.after.mir
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,10 @@ | ||
// MIR for `get_union` after PreCodegen | ||
|
||
fn get_union() -> Foo { | ||
let mut _0: Foo; // return place in scope 0 at $DIR/remove_zsts.rs:+0:19: +0:22 | ||
|
||
bb0: { | ||
Deinit(_0); // scope 0 at $DIR/remove_zsts.rs:+1:5: +1:18 | ||
return; // scope 0 at $DIR/remove_zsts.rs:+2:2: +2: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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
- // MIR for `get_union` before RemoveZsts | ||
+ // MIR for `get_union` after RemoveZsts | ||
|
||
fn get_union() -> Foo { | ||
let mut _0: Foo; // return place in scope 0 at $DIR/remove_zsts.rs:+0:19: +0:22 | ||
let mut _1: (); // in scope 0 at $DIR/remove_zsts.rs:+1:14: +1:16 | ||
|
||
bb0: { | ||
StorageLive(_1); // scope 0 at $DIR/remove_zsts.rs:+1:14: +1:16 | ||
- Deinit(_1); // scope 0 at $DIR/remove_zsts.rs:+1:14: +1:16 | ||
+ nop; // scope 0 at $DIR/remove_zsts.rs:+1:14: +1:16 | ||
Deinit(_0); // scope 0 at $DIR/remove_zsts.rs:+1:5: +1:18 | ||
- (_0.0: ()) = move _1; // scope 0 at $DIR/remove_zsts.rs:+1:5: +1:18 | ||
+ nop; // scope 0 at $DIR/remove_zsts.rs:+1:5: +1:18 | ||
StorageDead(_1); // scope 0 at $DIR/remove_zsts.rs:+1:17: +1:18 | ||
return; // scope 0 at $DIR/remove_zsts.rs:+2:2: +2: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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
union Foo { | ||
x: (), | ||
y: u64, | ||
} | ||
|
||
// EMIT_MIR remove_zsts.get_union.RemoveZsts.diff | ||
// EMIT_MIR remove_zsts.get_union.PreCodegen.after.mir | ||
fn get_union() -> Foo { | ||
Foo { x: () } | ||
} | ||
|
||
fn main() { | ||
get_union(); | ||
} |
15 changes: 0 additions & 15 deletions
15
src/test/mir-opt/remove_zsts_dont_touch_unions.get_union.RemoveZsts.after.mir
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.