-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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 #110826 - cjgillot:place-mention-use, r=JakobDegen,lcnr
Make PlaceMention a non-mutating use. Fixes #110781 r? `@JakobDegen` I don't agree with your statement in #110781 (comment). I suggest that we start fixing `PlaceContext` to be accurate enough for optimizations to use it. This structure is very convenient to use in visitors, and we perhaps have an opportunity to make it less of a footgun.
- Loading branch information
Showing
8 changed files
with
49 additions
and
10 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
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
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
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
25 changes: 25 additions & 0 deletions
25
tests/mir-opt/dead-store-elimination/place_mention.main.DeadStoreElimination.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,25 @@ | ||
- // MIR for `main` before DeadStoreElimination | ||
+ // MIR for `main` after DeadStoreElimination | ||
|
||
fn main() -> () { | ||
let mut _0: (); // return place in scope 0 at $DIR/place_mention.rs:+0:11: +0:11 | ||
let mut _1: (&str, &str); // in scope 0 at $DIR/place_mention.rs:+3:18: +3:36 | ||
scope 1 { | ||
} | ||
|
||
bb0: { | ||
StorageLive(_1); // scope 0 at $DIR/place_mention.rs:+3:18: +3:36 | ||
_1 = (const "Hello", const "World"); // scope 0 at $DIR/place_mention.rs:+3:18: +3:36 | ||
// mir::Constant | ||
// + span: $DIR/place_mention.rs:8:19: 8:26 | ||
// + literal: Const { ty: &str, val: Value(Slice(..)) } | ||
// mir::Constant | ||
// + span: $DIR/place_mention.rs:8:28: 8:35 | ||
// + literal: Const { ty: &str, val: Value(Slice(..)) } | ||
PlaceMention(_1); // scope 0 at $DIR/place_mention.rs:+3:18: +3:36 | ||
StorageDead(_1); // scope 0 at $DIR/place_mention.rs:+3:36: +3:37 | ||
_0 = const (); // scope 0 at $DIR/place_mention.rs:+0:11: +4:2 | ||
return; // scope 0 at $DIR/place_mention.rs:+4:2: +4: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,9 @@ | ||
// unit-test: DeadStoreElimination | ||
// compile-flags: -Zmir-keep-place-mention | ||
|
||
// EMIT_MIR place_mention.main.DeadStoreElimination.diff | ||
fn main() { | ||
// Verify that we account for the `PlaceMention` statement as a use of the tuple, | ||
// and don't remove it as a dead store. | ||
let (_, _) = ("Hello", "World"); | ||
} |