mir-opt: Do not handle the cleanup BB in the EarlyOtherwiseBranch
This commit is contained in:
parent
93aea1d0fe
commit
d08738c397
4 changed files with 53 additions and 86 deletions
|
@ -244,6 +244,10 @@ fn evaluate_candidate<'tcx>(
|
||||||
parent: BasicBlock,
|
parent: BasicBlock,
|
||||||
) -> Option<OptimizationData<'tcx>> {
|
) -> Option<OptimizationData<'tcx>> {
|
||||||
let bbs = &body.basic_blocks;
|
let bbs = &body.basic_blocks;
|
||||||
|
// NB: If this BB is a cleanup, we may need to figure out what else needs to be handled.
|
||||||
|
if bbs[parent].is_cleanup {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
let TerminatorKind::SwitchInt { targets, discr: parent_discr } = &bbs[parent].terminator().kind
|
let TerminatorKind::SwitchInt { targets, discr: parent_discr } = &bbs[parent].terminator().kind
|
||||||
else {
|
else {
|
||||||
return None;
|
return None;
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
let mut _7: bool;
|
let mut _7: bool;
|
||||||
let mut _8: bool;
|
let mut _8: bool;
|
||||||
let mut _9: isize;
|
let mut _9: isize;
|
||||||
+ let mut _10: bool;
|
|
||||||
scope 1 {
|
scope 1 {
|
||||||
debug _trailers => _5;
|
debug _trailers => _5;
|
||||||
}
|
}
|
||||||
|
@ -45,14 +44,12 @@
|
||||||
|
|
||||||
bb4: {
|
bb4: {
|
||||||
_0 = const ();
|
_0 = const ();
|
||||||
- goto -> bb17;
|
goto -> bb17;
|
||||||
+ goto -> bb15;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bb5: {
|
bb5: {
|
||||||
_0 = const ();
|
_0 = const ();
|
||||||
- goto -> bb17;
|
goto -> bb17;
|
||||||
+ goto -> bb15;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bb6: {
|
bb6: {
|
||||||
|
@ -60,26 +57,22 @@
|
||||||
_6 = copy ((((_1 as Ready).0: std::result::Result<std::option::Option<std::vec::Vec<u8>>, u8>) as Err).0: u8);
|
_6 = copy ((((_1 as Ready).0: std::result::Result<std::option::Option<std::vec::Vec<u8>>, u8>) as Err).0: u8);
|
||||||
_0 = const ();
|
_0 = const ();
|
||||||
StorageDead(_6);
|
StorageDead(_6);
|
||||||
- goto -> bb17;
|
goto -> bb17;
|
||||||
+ goto -> bb15;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bb7: {
|
bb7: {
|
||||||
StorageLive(_5);
|
StorageLive(_5);
|
||||||
_5 = move ((((((_1 as Ready).0: std::result::Result<std::option::Option<std::vec::Vec<u8>>, u8>) as Ok).0: std::option::Option<std::vec::Vec<u8>>) as Some).0: std::vec::Vec<u8>);
|
_5 = move ((((((_1 as Ready).0: std::result::Result<std::option::Option<std::vec::Vec<u8>>, u8>) as Ok).0: std::option::Option<std::vec::Vec<u8>>) as Some).0: std::vec::Vec<u8>);
|
||||||
_0 = const ();
|
_0 = const ();
|
||||||
- drop(_5) -> [return: bb8, unwind: bb20];
|
drop(_5) -> [return: bb8, unwind: bb20];
|
||||||
+ drop(_5) -> [return: bb8, unwind: bb16];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bb8: {
|
bb8: {
|
||||||
StorageDead(_5);
|
StorageDead(_5);
|
||||||
- goto -> bb17;
|
goto -> bb17;
|
||||||
+ goto -> bb15;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bb9 (cleanup): {
|
bb9 (cleanup): {
|
||||||
+ StorageDead(_10);
|
|
||||||
resume;
|
resume;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,8 +81,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
bb11: {
|
bb11: {
|
||||||
- switchInt(copy _7) -> [0: bb12, otherwise: bb16];
|
switchInt(copy _7) -> [0: bb12, otherwise: bb16];
|
||||||
+ switchInt(copy _7) -> [0: bb12, otherwise: bb14];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bb12: {
|
bb12: {
|
||||||
|
@ -98,45 +90,37 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
bb13: {
|
bb13: {
|
||||||
- switchInt(copy _8) -> [0: bb14, otherwise: bb15];
|
switchInt(copy _8) -> [0: bb14, otherwise: bb15];
|
||||||
- }
|
}
|
||||||
-
|
|
||||||
- bb14: {
|
bb14: {
|
||||||
_8 = const false;
|
_8 = const false;
|
||||||
goto -> bb12;
|
goto -> bb12;
|
||||||
}
|
}
|
||||||
|
|
||||||
- bb15: {
|
bb15: {
|
||||||
- goto -> bb14;
|
goto -> bb14;
|
||||||
- }
|
}
|
||||||
-
|
|
||||||
- bb16: {
|
bb16: {
|
||||||
+ bb14: {
|
|
||||||
_9 = discriminant(((_1 as Ready).0: std::result::Result<std::option::Option<std::vec::Vec<u8>>, u8>));
|
_9 = discriminant(((_1 as Ready).0: std::result::Result<std::option::Option<std::vec::Vec<u8>>, u8>));
|
||||||
switchInt(move _9) -> [0: bb13, otherwise: bb12];
|
switchInt(move _9) -> [0: bb13, otherwise: bb12];
|
||||||
}
|
}
|
||||||
|
|
||||||
- bb17: {
|
bb17: {
|
||||||
+ bb15: {
|
|
||||||
switchInt(copy _4) -> [0: bb11, otherwise: bb10];
|
switchInt(copy _4) -> [0: bb11, otherwise: bb10];
|
||||||
}
|
}
|
||||||
|
|
||||||
- bb18 (cleanup): {
|
bb18 (cleanup): {
|
||||||
- switchInt(copy _3) -> [0: bb19, otherwise: bb9];
|
switchInt(copy _3) -> [0: bb19, otherwise: bb9];
|
||||||
+ bb16 (cleanup): {
|
|
||||||
+ StorageLive(_10);
|
|
||||||
+ _10 = Ne(copy _4, copy _3);
|
|
||||||
+ switchInt(move _10) -> [0: bb17, otherwise: bb9];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- bb19 (cleanup): {
|
bb19 (cleanup): {
|
||||||
+ bb17 (cleanup): {
|
|
||||||
+ StorageDead(_10);
|
|
||||||
goto -> bb9;
|
goto -> bb9;
|
||||||
- }
|
}
|
||||||
-
|
|
||||||
- bb20 (cleanup): {
|
bb20 (cleanup): {
|
||||||
- switchInt(copy _4) -> [0: bb18, otherwise: bb9];
|
switchInt(copy _4) -> [0: bb18, otherwise: bb9];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,16 +6,14 @@ use std::task::Poll;
|
||||||
|
|
||||||
// We find a matching pattern in the unwind path,
|
// We find a matching pattern in the unwind path,
|
||||||
// and we need to create a cleanup BB for this case to meet the unwind invariants rule.
|
// and we need to create a cleanup BB for this case to meet the unwind invariants rule.
|
||||||
|
// NB: This transform is not happening currently.
|
||||||
|
|
||||||
// EMIT_MIR early_otherwise_branch_unwind.unwind.EarlyOtherwiseBranch.diff
|
// EMIT_MIR early_otherwise_branch_unwind.unwind.EarlyOtherwiseBranch.diff
|
||||||
fn unwind<T>(val: Option<Option<Option<T>>>) {
|
fn unwind<T>(val: Option<Option<Option<T>>>) {
|
||||||
// CHECK-LABEL: fn unwind(
|
// CHECK-LABEL: fn unwind(
|
||||||
// CHECK: drop({{.*}}) -> [return: bb{{.*}}, unwind: [[PARENT_UNWIND_BB:bb.*]]];
|
// CHECK: drop({{.*}}) -> [return: bb{{.*}}, unwind: [[PARENT_UNWIND_BB:bb.*]]];
|
||||||
// CHECK: [[PARENT_UNWIND_BB]] (cleanup): {
|
// CHECK: [[PARENT_UNWIND_BB]] (cleanup): {
|
||||||
// CHECK-NEXT: StorageLive
|
// CHECK-NEXT: switchInt
|
||||||
// CHECK-NEXT: [[CMP_LOCAL:_.*]] = Ne
|
|
||||||
// CHECK-NEXT: switchInt(move [[CMP_LOCAL]]) -> [0: [[NEW_UNWIND_BB:bb.*]], otherwise
|
|
||||||
// CHECK: [[NEW_UNWIND_BB]] (cleanup): {
|
|
||||||
match val {
|
match val {
|
||||||
Some(Some(Some(_v))) => {}
|
Some(Some(Some(_v))) => {}
|
||||||
Some(Some(None)) => {}
|
Some(Some(None)) => {}
|
||||||
|
@ -30,10 +28,7 @@ pub fn poll(val: Poll<Result<Option<Vec<u8>>, u8>>) {
|
||||||
// CHECK-LABEL: fn poll(
|
// CHECK-LABEL: fn poll(
|
||||||
// CHECK: drop({{.*}}) -> [return: bb{{.*}}, unwind: [[PARENT_UNWIND_BB:bb.*]]];
|
// CHECK: drop({{.*}}) -> [return: bb{{.*}}, unwind: [[PARENT_UNWIND_BB:bb.*]]];
|
||||||
// CHECK: [[PARENT_UNWIND_BB]] (cleanup): {
|
// CHECK: [[PARENT_UNWIND_BB]] (cleanup): {
|
||||||
// CHECK-NEXT: StorageLive
|
// CHECK-NEXT: switchInt
|
||||||
// CHECK-NEXT: [[CMP_LOCAL:_.*]] = Ne
|
|
||||||
// CHECK-NEXT: switchInt(move [[CMP_LOCAL]]) -> [0: [[NEW_UNWIND_BB:bb.*]], otherwise
|
|
||||||
// CHECK: [[NEW_UNWIND_BB]] (cleanup): {
|
|
||||||
match val {
|
match val {
|
||||||
Poll::Ready(Ok(Some(_trailers))) => {}
|
Poll::Ready(Ok(Some(_trailers))) => {}
|
||||||
Poll::Ready(Err(_err)) => {}
|
Poll::Ready(Err(_err)) => {}
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
let mut _6: bool;
|
let mut _6: bool;
|
||||||
let mut _7: bool;
|
let mut _7: bool;
|
||||||
let mut _8: isize;
|
let mut _8: isize;
|
||||||
+ let mut _9: bool;
|
|
||||||
scope 1 {
|
scope 1 {
|
||||||
debug _v => _5;
|
debug _v => _5;
|
||||||
}
|
}
|
||||||
|
@ -41,38 +40,32 @@
|
||||||
|
|
||||||
bb4: {
|
bb4: {
|
||||||
_0 = const ();
|
_0 = const ();
|
||||||
- goto -> bb17;
|
goto -> bb17;
|
||||||
+ goto -> bb15;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bb5: {
|
bb5: {
|
||||||
_0 = const ();
|
_0 = const ();
|
||||||
- goto -> bb17;
|
goto -> bb17;
|
||||||
+ goto -> bb15;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bb6: {
|
bb6: {
|
||||||
_0 = const ();
|
_0 = const ();
|
||||||
- goto -> bb17;
|
goto -> bb17;
|
||||||
+ goto -> bb15;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bb7: {
|
bb7: {
|
||||||
StorageLive(_5);
|
StorageLive(_5);
|
||||||
_5 = move ((((((_1 as Some).0: std::option::Option<std::option::Option<T>>) as Some).0: std::option::Option<T>) as Some).0: T);
|
_5 = move ((((((_1 as Some).0: std::option::Option<std::option::Option<T>>) as Some).0: std::option::Option<T>) as Some).0: T);
|
||||||
_0 = const ();
|
_0 = const ();
|
||||||
- drop(_5) -> [return: bb8, unwind: bb20];
|
drop(_5) -> [return: bb8, unwind: bb20];
|
||||||
+ drop(_5) -> [return: bb8, unwind: bb16];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bb8: {
|
bb8: {
|
||||||
StorageDead(_5);
|
StorageDead(_5);
|
||||||
- goto -> bb17;
|
goto -> bb17;
|
||||||
+ goto -> bb15;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bb9 (cleanup): {
|
bb9 (cleanup): {
|
||||||
+ StorageDead(_9);
|
|
||||||
resume;
|
resume;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,8 +74,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
bb11: {
|
bb11: {
|
||||||
- switchInt(copy _6) -> [0: bb12, otherwise: bb16];
|
switchInt(copy _6) -> [0: bb12, otherwise: bb16];
|
||||||
+ switchInt(copy _6) -> [0: bb12, otherwise: bb14];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bb12: {
|
bb12: {
|
||||||
|
@ -91,45 +83,37 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
bb13: {
|
bb13: {
|
||||||
- switchInt(copy _7) -> [0: bb14, otherwise: bb15];
|
switchInt(copy _7) -> [0: bb14, otherwise: bb15];
|
||||||
- }
|
}
|
||||||
-
|
|
||||||
- bb14: {
|
bb14: {
|
||||||
_7 = const false;
|
_7 = const false;
|
||||||
goto -> bb12;
|
goto -> bb12;
|
||||||
}
|
}
|
||||||
|
|
||||||
- bb15: {
|
bb15: {
|
||||||
- goto -> bb14;
|
goto -> bb14;
|
||||||
- }
|
}
|
||||||
-
|
|
||||||
- bb16: {
|
bb16: {
|
||||||
+ bb14: {
|
|
||||||
_8 = discriminant(((_1 as Some).0: std::option::Option<std::option::Option<T>>));
|
_8 = discriminant(((_1 as Some).0: std::option::Option<std::option::Option<T>>));
|
||||||
switchInt(move _8) -> [1: bb13, otherwise: bb12];
|
switchInt(move _8) -> [1: bb13, otherwise: bb12];
|
||||||
}
|
}
|
||||||
|
|
||||||
- bb17: {
|
bb17: {
|
||||||
+ bb15: {
|
|
||||||
switchInt(copy _4) -> [1: bb11, otherwise: bb10];
|
switchInt(copy _4) -> [1: bb11, otherwise: bb10];
|
||||||
}
|
}
|
||||||
|
|
||||||
- bb18 (cleanup): {
|
bb18 (cleanup): {
|
||||||
- switchInt(copy _3) -> [1: bb19, otherwise: bb9];
|
switchInt(copy _3) -> [1: bb19, otherwise: bb9];
|
||||||
+ bb16 (cleanup): {
|
|
||||||
+ StorageLive(_9);
|
|
||||||
+ _9 = Ne(copy _4, copy _3);
|
|
||||||
+ switchInt(move _9) -> [0: bb17, otherwise: bb9];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- bb19 (cleanup): {
|
bb19 (cleanup): {
|
||||||
+ bb17 (cleanup): {
|
|
||||||
+ StorageDead(_9);
|
|
||||||
goto -> bb9;
|
goto -> bb9;
|
||||||
- }
|
}
|
||||||
-
|
|
||||||
- bb20 (cleanup): {
|
bb20 (cleanup): {
|
||||||
- switchInt(copy _4) -> [1: bb18, otherwise: bb9];
|
switchInt(copy _4) -> [1: bb18, otherwise: bb9];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue