mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 08:44:35 +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); ```
163 lines
4.2 KiB
Diff
163 lines
4.2 KiB
Diff
- // MIR for `enum_identical_variant` before GVN
|
|
+ // MIR for `enum_identical_variant` after GVN
|
|
|
|
fn enum_identical_variant(_1: &Enum1) -> Enum1 {
|
|
debug v => _1;
|
|
let mut _0: Enum1;
|
|
let mut _2: isize;
|
|
let _3: &AllCopy;
|
|
let mut _8: i32;
|
|
let mut _9: u64;
|
|
let mut _10: [i8; 3];
|
|
let mut _11: AllCopy;
|
|
let _12: &AllCopy;
|
|
let mut _17: i32;
|
|
let mut _18: u64;
|
|
let mut _19: [i8; 3];
|
|
let mut _20: AllCopy;
|
|
scope 1 {
|
|
debug v => _3;
|
|
let _4: i32;
|
|
scope 2 {
|
|
debug a => _4;
|
|
let _5: u64;
|
|
scope 3 {
|
|
debug b => _5;
|
|
let _6: [i8; 3];
|
|
scope 4 {
|
|
debug c => _6;
|
|
let _7: AllCopy;
|
|
scope 5 {
|
|
debug all_copy => _7;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
scope 6 {
|
|
debug v => _12;
|
|
let _13: i32;
|
|
scope 7 {
|
|
debug a => _13;
|
|
let _14: u64;
|
|
scope 8 {
|
|
debug b => _14;
|
|
let _15: [i8; 3];
|
|
scope 9 {
|
|
debug c => _15;
|
|
let _16: AllCopy;
|
|
scope 10 {
|
|
debug all_copy => _16;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
bb0: {
|
|
_2 = discriminant((*_1));
|
|
switchInt(move _2) -> [0: bb3, 1: bb2, otherwise: bb1];
|
|
}
|
|
|
|
bb1: {
|
|
unreachable;
|
|
}
|
|
|
|
bb2: {
|
|
StorageLive(_12);
|
|
_12 = &(((*_1) as B).0: AllCopy);
|
|
- StorageLive(_13);
|
|
- _13 = copy ((*_12).0: i32);
|
|
- StorageLive(_14);
|
|
- _14 = copy ((*_12).1: u64);
|
|
- StorageLive(_15);
|
|
- _15 = copy ((*_12).2: [i8; 3]);
|
|
- StorageLive(_16);
|
|
+ nop;
|
|
+ _13 = copy ((((*_1) as B).0: AllCopy).0: i32);
|
|
+ nop;
|
|
+ _14 = copy ((((*_1) as B).0: AllCopy).1: u64);
|
|
+ nop;
|
|
+ _15 = copy ((((*_1) as B).0: AllCopy).2: [i8; 3]);
|
|
+ nop;
|
|
StorageLive(_17);
|
|
_17 = copy _13;
|
|
StorageLive(_18);
|
|
_18 = copy _14;
|
|
StorageLive(_19);
|
|
_19 = copy _15;
|
|
- _16 = AllCopy { a: move _17, b: move _18, c: move _19 };
|
|
+ _16 = copy (((*_1) as B).0: AllCopy);
|
|
StorageDead(_19);
|
|
StorageDead(_18);
|
|
StorageDead(_17);
|
|
StorageLive(_20);
|
|
- _20 = move _16;
|
|
- _0 = Enum1::B(move _20);
|
|
+ _20 = copy _16;
|
|
+ _0 = copy (*_1);
|
|
StorageDead(_20);
|
|
- StorageDead(_16);
|
|
- StorageDead(_15);
|
|
- StorageDead(_14);
|
|
- StorageDead(_13);
|
|
+ nop;
|
|
+ nop;
|
|
+ nop;
|
|
+ nop;
|
|
StorageDead(_12);
|
|
goto -> bb4;
|
|
}
|
|
|
|
bb3: {
|
|
StorageLive(_3);
|
|
_3 = &(((*_1) as A).0: AllCopy);
|
|
- StorageLive(_4);
|
|
- _4 = copy ((*_3).0: i32);
|
|
- StorageLive(_5);
|
|
- _5 = copy ((*_3).1: u64);
|
|
- StorageLive(_6);
|
|
- _6 = copy ((*_3).2: [i8; 3]);
|
|
- StorageLive(_7);
|
|
+ nop;
|
|
+ _4 = copy ((((*_1) as A).0: AllCopy).0: i32);
|
|
+ nop;
|
|
+ _5 = copy ((((*_1) as A).0: AllCopy).1: u64);
|
|
+ nop;
|
|
+ _6 = copy ((((*_1) as A).0: AllCopy).2: [i8; 3]);
|
|
+ nop;
|
|
StorageLive(_8);
|
|
_8 = copy _4;
|
|
StorageLive(_9);
|
|
_9 = copy _5;
|
|
StorageLive(_10);
|
|
_10 = copy _6;
|
|
- _7 = AllCopy { a: move _8, b: move _9, c: move _10 };
|
|
+ _7 = copy (((*_1) as A).0: AllCopy);
|
|
StorageDead(_10);
|
|
StorageDead(_9);
|
|
StorageDead(_8);
|
|
StorageLive(_11);
|
|
- _11 = move _7;
|
|
- _0 = Enum1::A(move _11);
|
|
+ _11 = copy _7;
|
|
+ _0 = copy (*_1);
|
|
StorageDead(_11);
|
|
- StorageDead(_7);
|
|
- StorageDead(_6);
|
|
- StorageDead(_5);
|
|
- StorageDead(_4);
|
|
+ nop;
|
|
+ nop;
|
|
+ nop;
|
|
+ nop;
|
|
StorageDead(_3);
|
|
goto -> bb4;
|
|
}
|
|
|
|
bb4: {
|
|
return;
|
|
}
|
|
}
|
|
|