rust/tests/mir-opt/const_prop/control_flow_simplification.hello.GVN.panic-unwind.diff
dianqk 9d999bb035
Do not use for_each_assignment_mut to iterate over assignment statements
`for_each_assignment_mut` can skip assignment statements with side effects,
which can result in some assignment statements retrieving outdated value.
For example, it may skip a dereference assignment statement.
2025-04-02 19:27:17 +08:00

26 lines
581 B
Diff

- // MIR for `hello` before GVN
+ // MIR for `hello` after GVN
fn hello() -> () {
let mut _0: ();
let mut _1: bool;
let mut _2: !;
bb0: {
StorageLive(_1);
- _1 = const <bool as NeedsDrop>::NEEDS;
- switchInt(move _1) -> [0: bb2, otherwise: bb1];
+ _1 = const false;
+ switchInt(const false) -> [0: bb2, otherwise: bb1];
}
bb1: {
_2 = begin_panic::<&str>(const "explicit panic") -> unwind continue;
}
bb2: {
StorageDead(_1);
return;
}
}