rust/tests/mir-opt/inline/exponential_runtime.main.Inline.panic-unwind.diff
Tomasz Miąsko 1be1c2ebcf Fix insertion of statements to be executed along return edge in inlining
Inlining creates additional statements to be executed along the return
edge: an assignment to the destination, storage end for temporaries.

Previously those statements where inserted directly into a call target,
but this is incorrect when the target has other predecessors.

Avoid the issue by creating a new dedicated block for those statements.
When the block happens to be redundant it will be removed by CFG
simplification that follows inlining.

Fixes #117355
2023-11-20 09:27:30 +01:00

135 lines
3.5 KiB
Diff

- // MIR for `main` before Inline
+ // MIR for `main` after Inline
fn main() -> () {
let mut _0: ();
let _1: ();
+ scope 1 (inlined <() as G>::call) {
+ let _2: ();
+ let _3: ();
+ let _4: ();
+ scope 2 (inlined <() as F>::call) {
+ let _5: ();
+ let _6: ();
+ let _7: ();
+ scope 3 (inlined <() as E>::call) {
+ let _8: ();
+ let _9: ();
+ let _10: ();
+ scope 4 (inlined <() as D>::call) {
+ let _11: ();
+ let _12: ();
+ let _13: ();
+ scope 5 (inlined <() as C>::call) {
+ let _14: ();
+ let _15: ();
+ let _16: ();
+ scope 6 (inlined <() as B>::call) {
+ let _17: ();
+ let _18: ();
+ let _19: ();
+ }
+ }
+ }
+ }
+ }
+ }
bb0: {
StorageLive(_1);
- _1 = <() as G>::call() -> [return: bb1, unwind continue];
+ StorageLive(_2);
+ StorageLive(_3);
+ StorageLive(_4);
+ StorageLive(_5);
+ StorageLive(_6);
+ StorageLive(_7);
+ StorageLive(_8);
+ StorageLive(_9);
+ StorageLive(_10);
+ StorageLive(_11);
+ StorageLive(_12);
+ StorageLive(_13);
+ StorageLive(_14);
+ StorageLive(_15);
+ StorageLive(_16);
+ StorageLive(_17);
+ StorageLive(_18);
+ StorageLive(_19);
+ _17 = <() as A>::call() -> [return: bb12, unwind continue];
}
bb1: {
+ StorageDead(_4);
+ StorageDead(_3);
+ StorageDead(_2);
StorageDead(_1);
_0 = const ();
return;
+ }
+
+ bb2: {
+ _4 = <() as F>::call() -> [return: bb1, unwind continue];
+ }
+
+ bb3: {
+ StorageDead(_7);
+ StorageDead(_6);
+ StorageDead(_5);
+ _3 = <() as F>::call() -> [return: bb2, unwind continue];
+ }
+
+ bb4: {
+ _7 = <() as E>::call() -> [return: bb3, unwind continue];
+ }
+
+ bb5: {
+ StorageDead(_10);
+ StorageDead(_9);
+ StorageDead(_8);
+ _6 = <() as E>::call() -> [return: bb4, unwind continue];
+ }
+
+ bb6: {
+ _10 = <() as D>::call() -> [return: bb5, unwind continue];
+ }
+
+ bb7: {
+ StorageDead(_13);
+ StorageDead(_12);
+ StorageDead(_11);
+ _9 = <() as D>::call() -> [return: bb6, unwind continue];
+ }
+
+ bb8: {
+ _13 = <() as C>::call() -> [return: bb7, unwind continue];
+ }
+
+ bb9: {
+ StorageDead(_16);
+ StorageDead(_15);
+ StorageDead(_14);
+ _12 = <() as C>::call() -> [return: bb8, unwind continue];
+ }
+
+ bb10: {
+ _16 = <() as B>::call() -> [return: bb9, unwind continue];
+ }
+
+ bb11: {
+ StorageDead(_19);
+ StorageDead(_18);
+ StorageDead(_17);
+ _15 = <() as B>::call() -> [return: bb10, unwind continue];
+ }
+
+ bb12: {
+ _18 = <() as A>::call() -> [return: bb13, unwind continue];
+ }
+
+ bb13: {
+ _19 = <() as A>::call() -> [return: bb11, unwind continue];
}
}