Auto merge of #100087 - JakobDegen:mir-patch, r=tmiasko

Avoid invalidating the CFG in `MirPatch`

As a part of this change, we adjust `MirPatch` to not needlessly create unnecessary resume blocks.

r? `@tmiasko`
This commit is contained in:
bors 2022-08-04 13:24:57 +00:00
commit 3830ecaa8d
45 changed files with 32 additions and 209 deletions

View file

@ -102,10 +102,6 @@
StorageDead(_6); // scope 1 at $DIR/derefer_complex_case.rs:+1:39: +1:40
_5 = const (); // scope 1 at $DIR/derefer_complex_case.rs:+1:5: +1:40
goto -> bb2; // scope 1 at $DIR/derefer_complex_case.rs:+1:5: +1:40
+ }
+
+ bb8 (cleanup): {
+ resume; // scope 0 at $DIR/derefer_complex_case.rs:+0:1: +2:2
}
}

View file

@ -94,10 +94,6 @@
StorageDead(_2); // scope 1 at $DIR/derefer_terminator_test.rs:+8:1: +8:2
StorageDead(_1); // scope 0 at $DIR/derefer_terminator_test.rs:+8:1: +8:2
return; // scope 0 at $DIR/derefer_terminator_test.rs:+8:2: +8:2
+ }
+
+ bb6 (cleanup): {
+ resume; // scope 0 at $DIR/derefer_terminator_test.rs:+0:1: +8:2
}
}

View file

@ -49,10 +49,6 @@
StorageDead(_2); // scope 1 at $DIR/derefer_test.rs:+5:1: +5:2
StorageDead(_1); // scope 0 at $DIR/derefer_test.rs:+5:1: +5:2
return; // scope 0 at $DIR/derefer_test.rs:+5:2: +5:2
+ }
+
+ bb1 (cleanup): {
+ resume; // scope 0 at $DIR/derefer_test.rs:+0:1: +5:2
}
}

View file

@ -87,10 +87,6 @@
StorageDead(_2); // scope 1 at $DIR/derefer_test_multiple.rs:+7:1: +7:2
StorageDead(_1); // scope 0 at $DIR/derefer_test_multiple.rs:+7:1: +7:2
return; // scope 0 at $DIR/derefer_test_multiple.rs:+7:2: +7:2
+ }
+
+ bb1 (cleanup): {
+ resume; // scope 0 at $DIR/derefer_test_multiple.rs:+0:1: +7:2
}
}

View file

@ -57,10 +57,6 @@
StorageDead(_4); // scope 1 at $DIR/dyn-trait.rs:+2:24: +2:25
StorageDead(_2); // scope 0 at $DIR/dyn-trait.rs:+3:1: +3:2
return; // scope 0 at $DIR/dyn-trait.rs:+3:2: +3:2
+ }
+
+ bb3 (cleanup): {
+ resume; // scope 0 at $DIR/dyn-trait.rs:+0:1: +3:2
}
}

View file

@ -32,10 +32,6 @@
+ StorageDead(_4); // scope 1 at $DIR/dyn-trait.rs:+0:21: +0:22
StorageDead(_2); // scope 0 at $DIR/dyn-trait.rs:+1:15: +1:16
return; // scope 0 at $DIR/dyn-trait.rs:+2:2: +2:2
+ }
+
+ bb2 (cleanup): {
+ resume; // scope 0 at $DIR/dyn-trait.rs:+0:1: +2:2
}
}

View file

@ -41,8 +41,4 @@ fn bar() -> bool {
StorageDead(_1); // scope 0 at $DIR/inline-any-operand.rs:+3:1: +3:2
return; // scope 0 at $DIR/inline-any-operand.rs:+3:2: +3:2
}
bb1 (cleanup): {
resume; // scope 0 at $DIR/inline-any-operand.rs:+0:1: +3:2
}
}

View file

@ -46,8 +46,4 @@ fn foo(_1: T, _2: i32) -> i32 {
StorageDead(_3); // scope 0 at $DIR/inline-closure.rs:+3:1: +3:2
return; // scope 0 at $DIR/inline-closure.rs:+3:2: +3:2
}
bb1 (cleanup): {
resume; // scope 0 at $DIR/inline-closure.rs:+0:1: +3:2
}
}

View file

@ -53,8 +53,4 @@ fn foo(_1: T, _2: &i32) -> i32 {
StorageDead(_3); // scope 0 at $DIR/inline-closure-borrows-arg.rs:+6:1: +6:2
return; // scope 0 at $DIR/inline-closure-borrows-arg.rs:+6:2: +6:2
}
bb1 (cleanup): {
resume; // scope 0 at $DIR/inline-closure-borrows-arg.rs:+0:1: +6:2
}
}

View file

@ -66,8 +66,4 @@ fn foo(_1: T, _2: i32) -> (i32, T) {
StorageDead(_3); // scope 0 at $DIR/inline-closure-captures.rs:+3:1: +3:2
return; // scope 0 at $DIR/inline-closure-captures.rs:+3:2: +3:2
}
bb1 (cleanup): {
resume; // scope 0 at $DIR/inline-closure-captures.rs:+0:1: +3:2
}
}

View file

@ -19,10 +19,6 @@
StorageDead(_1); // scope 0 at $DIR/inline-compatibility.rs:+1:18: +1:19
_0 = const (); // scope 0 at $DIR/inline-compatibility.rs:+0:37: +2:2
return; // scope 0 at $DIR/inline-compatibility.rs:+2:2: +2:2
+ }
+
+ bb1 (cleanup): {
+ resume; // scope 0 at $DIR/inline-compatibility.rs:+0:1: +2:2
}
}

View file

@ -19,10 +19,6 @@
StorageDead(_1); // scope 0 at $DIR/inline-compatibility.rs:+1:21: +1:22
_0 = const (); // scope 0 at $DIR/inline-compatibility.rs:+0:40: +2:2
return; // scope 0 at $DIR/inline-compatibility.rs:+2:2: +2:2
+ }
+
+ bb1 (cleanup): {
+ resume; // scope 0 at $DIR/inline-compatibility.rs:+0:1: +2:2
}
}

View file

@ -25,10 +25,6 @@
StorageDead(_1); // scope 0 at $DIR/inline-cycle.rs:+1:24: +1:25
_0 = const (); // scope 0 at $DIR/inline-cycle.rs:+0:10: +2:2
return; // scope 0 at $DIR/inline-cycle.rs:+2:2: +2:2
+ }
+
+ bb2 (cleanup): {
+ resume; // scope 0 at $DIR/inline-cycle.rs:+0:1: +2:2
}
}

View file

@ -50,10 +50,6 @@
StorageDead(_1); // scope 0 at $DIR/inline-cycle.rs:+1:12: +1:13
_0 = const (); // scope 0 at $DIR/inline-cycle.rs:+0:10: +2:2
return; // scope 0 at $DIR/inline-cycle.rs:+2:2: +2:2
+ }
+
+ bb2 (cleanup): {
+ resume; // scope 0 at $DIR/inline-cycle.rs:+0:1: +2:2
}
}

View file

@ -27,10 +27,6 @@
StorageDead(_1); // scope 0 at $DIR/inline-cycle-generic.rs:+1:24: +1:25
_0 = const (); // scope 0 at $DIR/inline-cycle-generic.rs:+0:11: +2:2
return; // scope 0 at $DIR/inline-cycle-generic.rs:+2:2: +2:2
+ }
+
+ bb2 (cleanup): {
+ resume; // scope 0 at $DIR/inline-cycle-generic.rs:+0:1: +2:2
}
}

View file

@ -19,10 +19,6 @@
+
+ bb1: {
+ goto -> bb1; // scope 1 at $DIR/inline-diverging.rs:+32:5: +32:12
+ }
+
+ bb2 (cleanup): {
+ resume; // scope 0 at $DIR/inline-diverging.rs:+0:1: +2:2
}
}

View file

@ -44,10 +44,6 @@
+ // mir::Constant
+ // + span: $SRC_DIR/std/src/panic.rs:LL:COL
+ // + literal: Const { ty: &str, val: Value(Slice(..)) }
+ }
+
+ bb3 (cleanup): {
+ resume; // scope 0 at $DIR/inline-diverging.rs:+0:1: +6:2
}
}

View file

@ -51,10 +51,6 @@
+
+ bb1: {
+ goto -> bb1; // scope 5 at $DIR/inline-diverging.rs:+18:5: +18:12
+ }
+
+ bb2 (cleanup): {
+ resume; // scope 0 at $DIR/inline-diverging.rs:+0:1: +2:2
}
}

View file

@ -39,10 +39,6 @@
StorageDead(_3); // scope 0 at $DIR/inline-instruction-set.rs:+3:30: +3:31
_0 = const (); // scope 0 at $DIR/inline-instruction-set.rs:+0:18: +4:2
return; // scope 0 at $DIR/inline-instruction-set.rs:+4:2: +4:2
+ }
+
+ bb3 (cleanup): {
+ resume; // scope 0 at $DIR/inline-instruction-set.rs:+0:1: +4:2
}
}

View file

@ -41,10 +41,6 @@
StorageDead(_3); // scope 0 at $DIR/inline-instruction-set.rs:+5:30: +5:31
_0 = const (); // scope 0 at $DIR/inline-instruction-set.rs:+0:14: +6:2
return; // scope 0 at $DIR/inline-instruction-set.rs:+6:2: +6:2
+ }
+
+ bb3 (cleanup): {
+ resume; // scope 0 at $DIR/inline-instruction-set.rs:+0:1: +6:2
}
}

View file

@ -52,8 +52,4 @@ fn main() -> () {
_0 = const (); // scope 0 at $DIR/inline-options.rs:+0:11: +3:2
return; // scope 0 at $DIR/inline-options.rs:+3:2: +3:2
}
bb5 (cleanup): {
resume; // scope 0 at $DIR/inline-options.rs:+0:1: +3:2
}
}

View file

@ -69,8 +69,4 @@ fn bar() -> bool {
StorageDead(_4); // scope 0 at $DIR/inline-retag.rs:+3:1: +3:2
return; // scope 0 at $DIR/inline-retag.rs:+3:2: +3:2
}
bb1 (cleanup): {
resume; // scope 0 at $DIR/inline-retag.rs:+0:1: +3:2
}
}

View file

@ -21,10 +21,6 @@
+ _0 = (*_2); // scope 1 at $SRC_DIR/core/src/clone.rs:LL:COL
StorageDead(_2); // scope 0 at $DIR/inline-shims.rs:+1:13: +1:14
return; // scope 0 at $DIR/inline-shims.rs:+2:2: +2:2
+ }
+
+ bb1 (cleanup): {
+ resume; // scope 0 at $DIR/inline-shims.rs:+0:1: +2:2
}
}

View file

@ -51,10 +51,6 @@
+
+ bb3: {
+ drop((((*_5) as Some).0: B)) -> bb2; // scope 3 at $SRC_DIR/core/src/ptr/mod.rs:LL:COL
+ }
+
+ bb4 (cleanup): {
+ resume; // scope 0 at $DIR/inline-shims.rs:+0:1: +3:2
}
}

View file

@ -23,10 +23,6 @@
_0 = const (); // scope 0 at $DIR/inline-specialization.rs:+0:11: +2:2
StorageDead(_1); // scope 0 at $DIR/inline-specialization.rs:+2:1: +2:2
return; // scope 0 at $DIR/inline-specialization.rs:+2:2: +2:2
+ }
+
+ bb1 (cleanup): {
+ resume; // scope 0 at $DIR/inline-specialization.rs:+0:1: +2:2
}
}

View file

@ -29,8 +29,4 @@ fn test2(_1: &dyn X) -> bool {
StorageDead(_2); // scope 0 at $DIR/inline-trait-method_2.rs:+1:11: +1:12
return; // scope 0 at $DIR/inline-trait-method_2.rs:+2:2: +2:2
}
bb2 (cleanup): {
resume; // scope 0 at $DIR/inline-trait-method_2.rs:+0:1: +2:2
}
}

View file

@ -27,8 +27,4 @@ fn a(_1: &mut [T]) -> &mut [T] {
StorageDead(_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+2:1: +2:2
return; // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+2:2: +2:2
}
bb1 (cleanup): {
resume; // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+0:1: +2:2
}
}

View file

@ -39,8 +39,4 @@ fn b(_1: &mut Box<T>) -> &mut T {
StorageDead(_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+2:1: +2:2
return; // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+2:2: +2:2
}
bb1 (cleanup): {
resume; // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+0:1: +2:2
}
}

View file

@ -19,8 +19,4 @@ fn c(_1: &[T]) -> &[T] {
StorageDead(_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+2:1: +2:2
return; // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+2:2: +2:2
}
bb1 (cleanup): {
resume; // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+0:1: +2:2
}
}

View file

@ -27,8 +27,4 @@ fn d(_1: &Box<T>) -> &T {
StorageDead(_2); // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+2:1: +2:2
return; // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+2:2: +2:2
}
bb1 (cleanup): {
resume; // scope 0 at $DIR/issue-58867-inline-as-ref-as-mut.rs:+0:1: +2:2
}
}

View file

@ -39,8 +39,4 @@ fn main() -> () {
StorageDead(_1); // scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:+3:1: +3:2
return; // scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:+3:2: +3:2
}
bb1 (cleanup): {
resume; // scope 0 at $DIR/issue-76997-inline-scopes-parenting.rs:+0:1: +3:2
}
}

View file

@ -16,9 +16,5 @@
bb1: {
return; // scope 0 at $DIR/lower_intrinsics.rs:+2:2: +2:2
}
bb2 (cleanup): {
resume; // scope 0 at $DIR/lower_intrinsics.rs:+0:1: +2:2
}
}

View file

@ -111,9 +111,5 @@
bb5: {
return; // scope 0 at $DIR/lower_intrinsics.rs:+5:2: +5:2
}
bb6 (cleanup): {
resume; // scope 0 at $DIR/lower_intrinsics.rs:+0:1: +5:2
}
}

View file

@ -25,9 +25,5 @@
bb2: {
return; // scope 0 at $DIR/lower_intrinsics.rs:+2:2: +2:2
}
bb3 (cleanup): {
resume; // scope 0 at $DIR/lower_intrinsics.rs:+0:1: +2:2
}
}

View file

@ -27,9 +27,5 @@
StorageDead(_1); // scope 0 at $DIR/lower_intrinsics.rs:+4:1: +4:2
return; // scope 0 at $DIR/lower_intrinsics.rs:+4:2: +4:2
}
bb2 (cleanup): {
resume; // scope 0 at $DIR/lower_intrinsics.rs:+0:1: +4:2
}
}

View file

@ -16,9 +16,5 @@
bb1: {
return; // scope 0 at $DIR/lower_intrinsics.rs:+2:2: +2:2
}
bb2 (cleanup): {
resume; // scope 0 at $DIR/lower_intrinsics.rs:+0:1: +2:2
}
}

View file

@ -18,9 +18,5 @@
- // + literal: Const { ty: unsafe extern "rust-intrinsic" fn() -> ! {std::intrinsics::unreachable}, val: Value(<ZST>) }
+ unreachable; // scope 1 at $DIR/lower_intrinsics.rs:+1:14: +1:45
}
bb1 (cleanup): {
resume; // scope 0 at $DIR/lower_intrinsics.rs:+0:1: +2:2
}
}

View file

@ -79,9 +79,5 @@
StorageDead(_3); // scope 0 at $DIR/lower_intrinsics.rs:+4:1: +4:2
return; // scope 0 at $DIR/lower_intrinsics.rs:+4:2: +4:2
}
bb4 (cleanup): {
resume; // scope 0 at $DIR/lower_intrinsics.rs:+0:1: +4:2
}
}

View file

@ -96,9 +96,5 @@
_10 = discriminant(_7); // scope 2 at $DIR/remove_storage_markers.rs:+2:14: +2:19
switchInt(move _10) -> [0_isize: bb3, otherwise: bb2]; // scope 2 at $DIR/remove_storage_markers.rs:+2:14: +2:19
}
bb5 (cleanup): {
resume; // scope 0 at $DIR/remove_storage_markers.rs:+0:1: +5:2
}
}

View file

@ -22,10 +22,6 @@
StorageDead(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:12: +1:13
- nop; // scope 0 at $DIR/remove_unneeded_drops.rs:+0:17: +2:2
return; // scope 0 at $DIR/remove_unneeded_drops.rs:+2:2: +2:2
- }
-
- bb2 (cleanup): {
- resume; // scope 0 at $DIR/remove_unneeded_drops.rs:+0:1: +2:2
}
}

View file

@ -22,10 +22,6 @@
StorageDead(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:12: +1:13
- nop; // scope 0 at $DIR/remove_unneeded_drops.rs:+0:36: +2:2
return; // scope 0 at $DIR/remove_unneeded_drops.rs:+2:2: +2:2
- }
-
- bb2 (cleanup): {
- resume; // scope 0 at $DIR/remove_unneeded_drops.rs:+0:1: +2:2
}
}

View file

@ -85,9 +85,5 @@
bb4: {
return; // scope 0 at $DIR/simplify-arm.rs:+6:2: +6:2
}
bb5 (cleanup): {
resume; // scope 0 at $DIR/simplify-arm.rs:+0:1: +6:2
}
}

View file

@ -85,9 +85,5 @@
bb4: {
return; // scope 0 at $DIR/simplify-arm.rs:+6:2: +6:2
}
bb5 (cleanup): {
resume; // scope 0 at $DIR/simplify-arm.rs:+0:1: +6:2
}
}