Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make UnwindAction::Continue explicit in MIR dump #112972

Merged
merged 2 commits into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion compiler/rustc_middle/src/mir/terminator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ impl<'tcx> Debug for TerminatorKind<'tcx> {

let unwind = match self.unwind() {
// Not needed or included in successors
None | Some(UnwindAction::Continue) | Some(UnwindAction::Cleanup(_)) => None,
None | Some(UnwindAction::Cleanup(_)) => None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, why aren't we also making Cleanup explicit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are already printed as successors

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleanup is the only unwind action that includes a basic block #

Some(UnwindAction::Continue) => Some("unwind continue"),
Some(UnwindAction::Unreachable) => Some("unwind unreachable"),
Some(UnwindAction::Terminate) => Some("unwind terminate"),
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn main() -> () {
StorageLive(_5);
StorageLive(_6);
_6 = _3;
_5 = foo(move _6) -> bb1;
_5 = foo(move _6) -> [return: bb1, unwind continue];
}

bb1: {
Expand All @@ -45,7 +45,7 @@ fn main() -> () {
_7 = _2;
_8 = Len(_1);
_9 = Lt(_7, _8);
assert(move _9, "index out of bounds: the length is {} but the index is {}", move _8, _7) -> bb2;
assert(move _9, "index out of bounds: the length is {} but the index is {}", move _8, _7) -> [success: bb2, unwind continue];
}

bb2: {
Expand Down
2 changes: 1 addition & 1 deletion tests/mir-opt/basic_assignment.main.ElaborateDrops.diff
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

bb4: {
StorageDead(_5);
- drop(_4) -> bb5;
- drop(_4) -> [return: bb5, unwind continue];
+ goto -> bb5;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ fn main() -> () {
StorageLive(_1);
_2 = SizeOf(S);
_3 = AlignOf(S);
_4 = alloc::alloc::exchange_malloc(move _2, move _3) -> bb1;
_4 = alloc::alloc::exchange_malloc(move _2, move _3) -> [return: bb1, unwind continue];
}

bb1: {
Expand All @@ -30,7 +30,7 @@ fn main() -> () {

bb2: {
_1 = move _5;
drop(_5) -> bb3;
drop(_5) -> [return: bb3, unwind continue];
}

bb3: {
Expand All @@ -45,7 +45,7 @@ fn main() -> () {
StorageDead(_7);
StorageDead(_6);
_0 = const ();
drop(_1) -> bb5;
drop(_1) -> [return: bb5, unwind continue];
}

bb5: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn a::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:11:14: 11:16]>
}

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

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

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

bb29: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fn direct_call(_1: i32) -> i32 {
let mut _0: i32;

bb0: {
_0 = ident::<i32>(_1) -> bb1;
_0 = ident::<i32>(_1) -> [return: bb1, unwind continue];
}

bb1: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fn drop_first(_1: WriteOnDrop<'_>, _2: WriteOnDrop<'_>) -> () {
let mut _0: ();

bb0: {
drop(_1) -> bb1;
drop(_1) -> [return: bb1, unwind continue];
}

bb1: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fn drop_second(_1: WriteOnDrop<'_>, _2: WriteOnDrop<'_>) -> () {
let mut _0: ();

bb0: {
drop(_2) -> bb1;
drop(_2) -> [return: bb1, unwind continue];
}

bb1: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ fn indirect_call(_1: i32, _2: fn(i32) -> i32) -> i32 {
let mut _0: i32;

bb0: {
_0 = _2(_1) -> bb1;
_0 = _2(_1) -> [return: bb1, unwind continue];
}

bb1: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
- _4 = Len(_1);
+ _4 = const 2_usize;
_5 = Lt(_3, _4);
assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1;
assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue];
}

bb1: {
Expand All @@ -44,7 +44,7 @@
- _8 = Len(_1);
+ _8 = const 2_usize;
_9 = Lt(_7, _8);
assert(move _9, "index out of bounds: the length is {} but the index is {}", move _8, _7) -> bb2;
assert(move _9, "index out of bounds: the length is {} but the index is {}", move _8, _7) -> [success: bb2, unwind continue];
}

bb2: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
_4 = &((*_1).0: T);
- _3 = &(*_4);
+ _3 = _4;
_2 = <T as Clone>::clone(move _3) -> bb1;
_2 = <T as Clone>::clone(move _3) -> [return: bb1, unwind continue];
}

bb1: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
StorageLive(_5);
- _5 = _1;
+ _5 = const 1_u8;
_4 = foo(move _5) -> bb1;
_4 = foo(move _5) -> [return: bb1, unwind continue];
}

bb1: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn main() -> () {
StorageLive(_4);
StorageLive(_5);
_5 = const 1_u8;
_4 = foo(move _5) -> bb1;
_4 = foo(move _5) -> [return: bb1, unwind continue];
}

bb1: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
_3 = const 2_usize;
- _4 = Len(_2);
- _5 = Lt(_3, _4);
- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1;
- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue];
+ _4 = const 4_usize;
+ _5 = const true;
+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1;
+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue];
}

bb1: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
_3 = const 2_usize;
- _4 = Len(_2);
- _5 = Lt(_3, _4);
- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1;
- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue];
+ _4 = const 4_usize;
+ _5 = const true;
+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1;
+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue];
}

bb1: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@
StorageLive(_3);
- _3 = _1;
- _4 = Eq(_3, const 0_i32);
- assert(!move _4, "attempt to divide `{}` by zero", const 1_i32) -> bb1;
- assert(!move _4, "attempt to divide `{}` by zero", const 1_i32) -> [success: bb1, unwind continue];
+ _3 = const 0_i32;
+ _4 = const true;
+ assert(!const true, "attempt to divide `{}` by zero", const 1_i32) -> bb1;
+ assert(!const true, "attempt to divide `{}` by zero", const 1_i32) -> [success: bb1, unwind continue];
}

bb1: {
- _5 = Eq(_3, const -1_i32);
- _6 = Eq(const 1_i32, const i32::MIN);
- _7 = BitAnd(move _5, move _6);
- assert(!move _7, "attempt to compute `{} / {}`, which would overflow", const 1_i32, _3) -> bb2;
- assert(!move _7, "attempt to compute `{} / {}`, which would overflow", const 1_i32, _3) -> [success: bb2, unwind continue];
+ _5 = const false;
+ _6 = const false;
+ _7 = const false;
+ assert(!const false, "attempt to compute `{} / {}`, which would overflow", const 1_i32, _3) -> bb2;
+ assert(!const false, "attempt to compute `{} / {}`, which would overflow", const 1_i32, _3) -> [success: bb2, unwind continue];
}

bb2: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,21 @@
StorageLive(_3);
- _3 = _1;
- _4 = Eq(_3, const 0_i32);
- assert(!move _4, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_i32) -> bb1;
- assert(!move _4, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_i32) -> [success: bb1, unwind continue];
+ _3 = const 0_i32;
+ _4 = const true;
+ assert(!const true, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_i32) -> bb1;
+ assert(!const true, "attempt to calculate the remainder of `{}` with a divisor of zero", const 1_i32) -> [success: bb1, unwind continue];
}

bb1: {
- _5 = Eq(_3, const -1_i32);
- _6 = Eq(const 1_i32, const i32::MIN);
- _7 = BitAnd(move _5, move _6);
- assert(!move _7, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, _3) -> bb2;
- assert(!move _7, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, _3) -> [success: bb2, unwind continue];
+ _5 = const false;
+ _6 = const false;
+ _7 = const false;
+ assert(!const false, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, _3) -> bb2;
+ assert(!const false, "attempt to compute the remainder of `{} % {}`, which would overflow", const 1_i32, _3) -> [success: bb2, unwind continue];
}

bb2: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
_6 = const 3_usize;
_7 = const 3_usize;
- _8 = Lt(_6, _7);
- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1;
- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue];
+ _8 = const false;
+ assert(const false, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1;
+ assert(const false, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue];
}

bb1: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
_6 = const 3_usize;
_7 = const 3_usize;
- _8 = Lt(_6, _7);
- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1;
- assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue];
+ _8 = const false;
+ assert(const false, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> bb1;
+ assert(const false, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue];
}

bb1: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
- _5 = AlignOf(i32);
+ _4 = const 4_usize;
+ _5 = const 4_usize;
_6 = alloc::alloc::exchange_malloc(move _4, move _5) -> bb1;
_6 = alloc::alloc::exchange_malloc(move _4, move _5) -> [return: bb1, unwind continue];
}

bb1: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
bb0: {
StorageLive(_1);
- _2 = CheckedAdd(const 1_u32, const 1_u32);
- assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 1_u32, const 1_u32) -> bb1;
- assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 1_u32, const 1_u32) -> [success: bb1, unwind continue];
+ _2 = const (2_u32, false);
+ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 1_u32, const 1_u32) -> bb1;
+ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 1_u32, const 1_u32) -> [success: bb1, unwind continue];
}

bb1: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
StorageLive(_4);
StorageLive(_5);
_5 = _1;
_4 = read(move _5) -> bb1;
_4 = read(move _5) -> [return: bb1, unwind continue];
}

bb1: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
}

bb1: {
_2 = begin_panic::<&str>(const "explicit panic");
_2 = begin_panic::<&str>(const "explicit panic") -> unwind continue;
}

bb2: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
StorageLive(_2);
- _2 = const 2_u32 as u8 (IntToInt);
- _3 = CheckedAdd(_2, const 1_u8);
- assert(!move (_3.1: bool), "attempt to compute `{} + {}`, which would overflow", move _2, const 1_u8) -> bb1;
- assert(!move (_3.1: bool), "attempt to compute `{} + {}`, which would overflow", move _2, const 1_u8) -> [success: bb1, unwind continue];
+ _2 = const 2_u8;
+ _3 = const (3_u8, false);
+ assert(!const false, "attempt to compute `{} + {}`, which would overflow", move _2, const 1_u8) -> bb1;
+ assert(!const false, "attempt to compute `{} + {}`, which would overflow", move _2, const 1_u8) -> [success: bb1, unwind continue];
}

bb1: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
StorageLive(_3);
_3 = const 1_u8;
- _4 = CheckedAdd(_2, _3);
- assert(!move (_4.1: bool), "attempt to compute `{} + {}`, which would overflow", _2, _3) -> bb1;
- assert(!move (_4.1: bool), "attempt to compute `{} + {}`, which would overflow", _2, _3) -> [success: bb1, unwind continue];
+ _4 = const (0_u8, true);
+ assert(!const true, "attempt to compute `{} + {}`, which would overflow", _2, _3) -> bb1;
+ assert(!const true, "attempt to compute `{} + {}`, which would overflow", _2, _3) -> [success: bb1, unwind continue];
}

bb1: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
bb0: {
StorageLive(_2);
_2 = (const (), const 0_u8, const 0_u8);
_1 = encode(move _2) -> bb1;
_1 = encode(move _2) -> [return: bb1, unwind continue];
}

bb1: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
+ _3 = const (1_u8, 2_u8);
_2 = (move _3,);
StorageDead(_3);
_1 = test(move _2) -> bb1;
_1 = test(move _2) -> [return: bb1, unwind continue];
}

bb1: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
_3 = const 2_usize;
- _4 = Len(_2);
- _5 = Lt(_3, _4);
- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1;
- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue];
+ _4 = const 5000_usize;
+ _5 = const true;
+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1;
+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue];
}

bb1: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
_3 = const 2_usize;
- _4 = Len(_2);
- _5 = Lt(_3, _4);
- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1;
- assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue];
+ _4 = const 5000_usize;
+ _5 = const true;
+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> bb1;
+ assert(const true, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue];
}

bb1: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

bb0: {
StorageLive(_1);
_1 = foo() -> bb1;
_1 = foo() -> [return: bb1, unwind continue];
}

bb1: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

bb0: {
StorageLive(_1);
_1 = foo() -> bb1;
_1 = foo() -> [return: bb1, unwind continue];
}

bb1: {
Expand Down