Skip to content

Commit

Permalink
Bless mir-opt
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Sep 23, 2023
1 parent 211d2ed commit d989e14
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,30 @@ fn a::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:11:14: 11:16}>

bb0: {
_5 = discriminant((*(_1.0: &mut {async fn body@$DIR/async_await.rs:11:14: 11:16})));
switchInt(move _5) -> [0: bb1, 1: bb2, otherwise: bb3];
switchInt(move _5) -> [0: bb1, 1: bb4, otherwise: bb5];
}

bb1: {
_4 = move _2;
_3 = const ();
goto -> bb3;
}

bb2: {
_0 = Poll::<()>::Ready(move _3);
discriminant((*(_1.0: &mut {async fn body@$DIR/async_await.rs:11:14: 11:16}))) = 1;
return;
}

bb2: {
assert(const false, "`async fn` resumed after completion") -> [success: bb2, unwind unreachable];
bb3: {
goto -> bb2;
}

bb3: {
bb4: {
assert(const false, "`async fn` resumed after completion") -> [success: bb4, unwind unreachable];
}

bb5: {
unreachable;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>,

bb0: {
_39 = discriminant((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2})));
switchInt(move _39) -> [0: bb1, 1: bb28, 3: bb26, 4: bb27, otherwise: bb29];
switchInt(move _39) -> [0: bb1, 1: bb29, 3: bb27, 4: bb28, otherwise: bb30];
}

bb1: {
Expand Down Expand Up @@ -187,7 +187,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>,
StorageDead(_12);
StorageDead(_9);
StorageDead(_8);
goto -> bb12;
drop((((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2})) as variant#3).0: impl std::future::Future<Output = ()>)) -> [return: bb12, unwind unreachable];
}

bb11: {
Expand Down Expand Up @@ -279,7 +279,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>,
StorageDead(_28);
StorageDead(_25);
StorageDead(_24);
goto -> bb23;
drop((((*(_1.0: &mut {async fn body@$DIR/async_await.rs:14:18: 17:2})) as variant#4).0: impl std::future::Future<Output = ()>)) -> [return: bb23, unwind unreachable];
}

bb22: {
Expand All @@ -297,7 +297,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>,

bb24: {
StorageDead(_21);
goto -> bb25;
goto -> bb26;
}

bb25: {
Expand All @@ -307,6 +307,10 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>,
}

bb26: {
goto -> bb25;
}

bb27: {
StorageLive(_3);
StorageLive(_4);
StorageLive(_19);
Expand All @@ -315,19 +319,19 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body@$DIR/async_await.rs:14:18: 17:2}>,
goto -> bb11;
}

bb27: {
bb28: {
StorageLive(_21);
StorageLive(_35);
StorageLive(_36);
_35 = move _2;
goto -> bb22;
}

bb28: {
assert(const false, "`async fn` resumed after completion") -> [success: bb28, unwind unreachable];
bb29: {
assert(const false, "`async fn` resumed after completion") -> [success: bb29, unwind unreachable];
}

bb29: {
bb30: {
unreachable;
}
}
71 changes: 38 additions & 33 deletions tests/mir-opt/inline/inline_generator.main.Inline.panic-abort.diff
Original file line number Diff line number Diff line change
Expand Up @@ -36,62 +36,67 @@
StorageLive(_3);
StorageLive(_4);
- _4 = g() -> [return: bb1, unwind unreachable];
- }
-
- bb1: {
+ _4 = {generator@$DIR/inline_generator.rs:16:5: 16:8 (#0)};
_3 = &mut _4;
- _2 = Pin::<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}>::new(move _3) -> [return: bb2, unwind unreachable];
- }
-
- bb2: {
+ _3 = &mut _4;
+ _2 = Pin::<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}> { pointer: move _3 };
StorageDead(_3);
- _1 = <{generator@$DIR/inline_generator.rs:16:5: 16:8} as Generator<bool>>::resume(move _2, const false) -> [return: bb3, unwind unreachable];
+ StorageDead(_3);
+ StorageLive(_5);
+ _5 = const false;
+ _6 = deref_copy (_2.0: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8});
+ _7 = discriminant((*_6));
+ switchInt(move _7) -> [0: bb2, 1: bb6, 3: bb7, otherwise: bb8];
+ switchInt(move _7) -> [0: bb3, 1: bb7, 3: bb8, otherwise: bb9];
}

- bb3: {
+ bb1: {
bb1: {
- _3 = &mut _4;
- _2 = Pin::<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}>::new(move _3) -> [return: bb2, unwind unreachable];
+ StorageDead(_5);
StorageDead(_2);
StorageDead(_4);
_0 = const ();
StorageDead(_1);
return;
+ }
+
+ bb2: {
+ StorageDead(_2);
+ drop(_4) -> [return: bb2, unwind unreachable];
}

bb2: {
- StorageDead(_3);
- _1 = <{generator@$DIR/inline_generator.rs:16:5: 16:8} as Generator<bool>>::resume(move _2, const false) -> [return: bb3, unwind unreachable];
+ StorageDead(_4);
+ _0 = const ();
+ StorageDead(_1);
+ return;
}

bb3: {
- StorageDead(_2);
- drop(_4) -> [return: bb4, unwind unreachable];
+ StorageLive(_8);
+ switchInt(_5) -> [0: bb3, otherwise: bb4];
+ }
+
+ bb3: {
+ switchInt(_5) -> [0: bb4, otherwise: bb5];
}

bb4: {
- StorageDead(_4);
- _0 = const ();
- StorageDead(_1);
- return;
+ _8 = const 13_i32;
+ goto -> bb5;
+ goto -> bb6;
+ }
+
+ bb4: {
+ bb5: {
+ _8 = const 7_i32;
+ goto -> bb5;
+ goto -> bb6;
+ }
+
+ bb5: {
+ bb6: {
+ _1 = GeneratorState::<i32, bool>::Yielded(move _8);
+ _9 = deref_copy (_2.0: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8});
+ discriminant((*_9)) = 3;
+ goto -> bb1;
+ }
+
+ bb6: {
+ assert(const false, "generator resumed after completion") -> [success: bb6, unwind unreachable];
+ bb7: {
+ assert(const false, "generator resumed after completion") -> [success: bb7, unwind unreachable];
+ }
+
+ bb7: {
+ bb8: {
+ StorageLive(_8);
+ StorageDead(_8);
+ _1 = GeneratorState::<i32, bool>::Complete(_5);
Expand All @@ -100,7 +105,7 @@
+ goto -> bb1;
+ }
+
+ bb8: {
+ bb9: {
+ unreachable;
}
}
Expand Down
44 changes: 28 additions & 16 deletions tests/mir-opt/inline/inline_generator.main.Inline.panic-unwind.diff
Original file line number Diff line number Diff line change
Expand Up @@ -41,62 +41,74 @@
- bb1: {
+ _4 = {generator@$DIR/inline_generator.rs:16:5: 16:8 (#0)};
_3 = &mut _4;
- _2 = Pin::<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}>::new(move _3) -> [return: bb2, unwind: bb4];
- _2 = Pin::<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}>::new(move _3) -> [return: bb2, unwind: bb5];
- }
-
- bb2: {
+ _2 = Pin::<&mut {generator@$DIR/inline_generator.rs:16:5: 16:8}> { pointer: move _3 };
StorageDead(_3);
- _1 = <{generator@$DIR/inline_generator.rs:16:5: 16:8} as Generator<bool>>::resume(move _2, const false) -> [return: bb3, unwind: bb4];
- _1 = <{generator@$DIR/inline_generator.rs:16:5: 16:8} as Generator<bool>>::resume(move _2, const false) -> [return: bb3, unwind: bb5];
+ StorageLive(_5);
+ _5 = const false;
+ _6 = deref_copy (_2.0: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8});
+ _7 = discriminant((*_6));
+ switchInt(move _7) -> [0: bb3, 1: bb7, 3: bb8, otherwise: bb9];
+ switchInt(move _7) -> [0: bb5, 1: bb9, 3: bb10, otherwise: bb11];
}

- bb3: {
+ bb1: {
+ StorageDead(_5);
StorageDead(_2);
- drop(_4) -> [return: bb4, unwind: bb6];
+ drop(_4) -> [return: bb2, unwind: bb4];
}

- bb4: {
+ bb2: {
StorageDead(_4);
_0 = const ();
StorageDead(_1);
return;
}

- bb4 (cleanup): {
+ bb2 (cleanup): {
- bb5 (cleanup): {
- drop(_4) -> [return: bb6, unwind terminate(cleanup)];
+ bb3 (cleanup): {
+ drop(_4) -> [return: bb4, unwind terminate(cleanup)];
}

- bb6 (cleanup): {
+ bb4 (cleanup): {
resume;
+ }
+
+ bb3: {
+ bb5: {
+ StorageLive(_8);
+ switchInt(_5) -> [0: bb4, otherwise: bb5];
+ switchInt(_5) -> [0: bb6, otherwise: bb7];
+ }
+
+ bb4: {
+ bb6: {
+ _8 = const 13_i32;
+ goto -> bb6;
+ goto -> bb8;
+ }
+
+ bb5: {
+ bb7: {
+ _8 = const 7_i32;
+ goto -> bb6;
+ goto -> bb8;
+ }
+
+ bb6: {
+ bb8: {
+ _1 = GeneratorState::<i32, bool>::Yielded(move _8);
+ _9 = deref_copy (_2.0: &mut {generator@$DIR/inline_generator.rs:16:5: 16:8});
+ discriminant((*_9)) = 3;
+ goto -> bb1;
+ }
+
+ bb7: {
+ assert(const false, "generator resumed after completion") -> [success: bb7, unwind: bb2];
+ bb9: {
+ assert(const false, "generator resumed after completion") -> [success: bb9, unwind: bb3];
+ }
+
+ bb8: {
+ bb10: {
+ StorageLive(_8);
+ StorageDead(_8);
+ _1 = GeneratorState::<i32, bool>::Complete(_5);
Expand All @@ -105,7 +117,7 @@
+ goto -> bb1;
+ }
+
+ bb9: {
+ bb11: {
+ unreachable;
}
}
Expand Down

0 comments on commit d989e14

Please sign in to comment.