mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
c16c22cc9c
The optimized clone method ends up as the following MIR: ``` _2 = copy ((*_1).0: i32); _3 = copy ((*_1).1: u64); _4 = copy ((*_1).2: [i8; 3]); _0 = Foo { a: move _2, b: move _3, c: move _4 }; ``` We can transform this to: ``` _0 = copy (*_1); ```
55 lines
1.3 KiB
Diff
55 lines
1.3 KiB
Diff
- // MIR for `remove_storage_dead` before GVN
|
|
+ // MIR for `remove_storage_dead` after GVN
|
|
|
|
fn remove_storage_dead(_1: fn() -> AlwaysSome<T>) -> AlwaysSome<T> {
|
|
debug f => _1;
|
|
let mut _0: AlwaysSome<T>;
|
|
let _2: T;
|
|
let mut _3: AlwaysSome<T>;
|
|
let mut _4: fn() -> AlwaysSome<T>;
|
|
let _5: T;
|
|
let mut _6: T;
|
|
let mut _7: isize;
|
|
let mut _8: isize;
|
|
scope 1 {
|
|
debug v => _2;
|
|
}
|
|
scope 2 {
|
|
debug v => _5;
|
|
}
|
|
|
|
bb0: {
|
|
StorageLive(_2);
|
|
- StorageLive(_3);
|
|
+ nop;
|
|
StorageLive(_4);
|
|
_4 = copy _1;
|
|
- _3 = move _4() -> [return: bb1, unwind unreachable];
|
|
+ _3 = copy _1() -> [return: bb1, unwind unreachable];
|
|
}
|
|
|
|
bb1: {
|
|
StorageDead(_4);
|
|
- StorageLive(_5);
|
|
- _5 = move ((_3 as Some).0: T);
|
|
- _2 = move _5;
|
|
- StorageDead(_5);
|
|
+ nop;
|
|
+ _5 = copy ((_3 as Some).0: T);
|
|
+ _2 = copy _5;
|
|
+ nop;
|
|
_7 = discriminant(_3);
|
|
- StorageDead(_3);
|
|
+ nop;
|
|
StorageLive(_6);
|
|
- _6 = move _2;
|
|
- _0 = AlwaysSome::<T>::Some(move _6);
|
|
+ _6 = copy _5;
|
|
+ _0 = copy _3;
|
|
StorageDead(_6);
|
|
StorageDead(_2);
|
|
return;
|
|
}
|
|
}
|
|
|