-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Turn projections into copies in CopyProp.
- Loading branch information
Showing
4 changed files
with
68 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
- // MIR for `f` before CopyProp | ||
+ // MIR for `f` after CopyProp | ||
|
||
fn f(_1: Foo) -> bool { | ||
let mut _0: bool; // return place in scope 0 at $DIR/move_projection.rs:+0:17: +0:21 | ||
let mut _2: Foo; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL | ||
let mut _3: u8; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL | ||
|
||
bb0: { | ||
- _2 = _1; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL | ||
- _3 = move (_2.0: u8); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL | ||
- _0 = opaque::<Foo>(move _1) -> bb1; // scope 0 at $DIR/move_projection.rs:+6:13: +6:44 | ||
+ _3 = (_1.0: u8); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL | ||
+ _0 = opaque::<Foo>(_1) -> bb1; // scope 0 at $DIR/move_projection.rs:+6:13: +6:44 | ||
// mir::Constant | ||
// + span: $DIR/move_projection.rs:19:28: 19:34 | ||
// + literal: Const { ty: fn(Foo) -> bool {opaque::<Foo>}, val: Value(<ZST>) } | ||
} | ||
|
||
bb1: { | ||
_0 = opaque::<u8>(move _3) -> bb2; // scope 0 at $DIR/move_projection.rs:+9:13: +9:44 | ||
// mir::Constant | ||
// + span: $DIR/move_projection.rs:22:28: 22:34 | ||
// + literal: Const { ty: fn(u8) -> bool {opaque::<u8>}, val: Value(<ZST>) } | ||
} | ||
|
||
bb2: { | ||
return; // scope 0 at $DIR/move_projection.rs:+12:13: +12:21 | ||
} | ||
} | ||
|
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,34 @@ | ||
// unit-test: CopyProp | ||
|
||
#![feature(custom_mir, core_intrinsics)] | ||
#![allow(unused_assignments)] | ||
extern crate core; | ||
use core::intrinsics::mir::*; | ||
|
||
fn opaque(_: impl Sized) -> bool { true } | ||
|
||
struct Foo(u8); | ||
|
||
#[custom_mir(dialect = "analysis", phase = "post-cleanup")] | ||
fn f(a: Foo) -> bool { | ||
mir!( | ||
{ | ||
let b = a; | ||
// This is a move out of a copy, so must become a copy of `a.0`. | ||
let c = Move(b.0); | ||
Call(RET, bb1, opaque(Move(a))) | ||
} | ||
bb1 = { | ||
Call(RET, ret, opaque(Move(c))) | ||
} | ||
ret = { | ||
Return() | ||
} | ||
) | ||
} | ||
|
||
fn main() { | ||
assert!(f(Foo(0))); | ||
} | ||
|
||
// EMIT_MIR move_projection.f.CopyProp.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