From b56ea88414ebd87051b69f27ff3ed55fe0ec12fc Mon Sep 17 00:00:00 2001 From: Oliver Scherer Date: Fri, 24 Jul 2020 15:54:15 +0200 Subject: [PATCH] Add a system for creating diffs across multiple mir optimizations. --- src/test/mir-opt/match-arm-scopes.rs | 3 +- ...complicated_match.ElaborateDrops.after.mir | 235 ------------- ...fg-initial.after-ElaborateDrops.after.diff | 313 ++++++++++++++++++ ...icated_match.SimplifyCfg-initial.after.mir | 246 -------------- src/tools/compiletest/src/runtest.rs | 53 ++- 5 files changed, 357 insertions(+), 493 deletions(-) delete mode 100644 src/test/mir-opt/match-arm-scopes/rustc.complicated_match.ElaborateDrops.after.mir create mode 100644 src/test/mir-opt/match-arm-scopes/rustc.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff delete mode 100644 src/test/mir-opt/match-arm-scopes/rustc.complicated_match.SimplifyCfg-initial.after.mir diff --git a/src/test/mir-opt/match-arm-scopes.rs b/src/test/mir-opt/match-arm-scopes.rs index 0e30a15671528..2c5816c51e3e2 100644 --- a/src/test/mir-opt/match-arm-scopes.rs +++ b/src/test/mir-opt/match-arm-scopes.rs @@ -9,8 +9,7 @@ // all of the bindings for that scope. // * No drop flags are used. -// EMIT_MIR rustc.complicated_match.SimplifyCfg-initial.after.mir -// EMIT_MIR rustc.complicated_match.ElaborateDrops.after.mir +// EMIT_MIR rustc.complicated_match SimplifyCfg-initial.after ElaborateDrops.after fn complicated_match(cond: bool, items: (bool, bool, String)) -> i32 { match items { (false, a, s) | (a, false, s) if if cond { return 3 } else { a } => 1, diff --git a/src/test/mir-opt/match-arm-scopes/rustc.complicated_match.ElaborateDrops.after.mir b/src/test/mir-opt/match-arm-scopes/rustc.complicated_match.ElaborateDrops.after.mir deleted file mode 100644 index df6a247bb5ff6..0000000000000 --- a/src/test/mir-opt/match-arm-scopes/rustc.complicated_match.ElaborateDrops.after.mir +++ /dev/null @@ -1,235 +0,0 @@ -// MIR for `complicated_match` after ElaborateDrops - -fn complicated_match(_1: bool, _2: (bool, bool, std::string::String)) -> i32 { - debug cond => _1; // in scope 0 at $DIR/match-arm-scopes.rs:14:22: 14:26 - debug items => _2; // in scope 0 at $DIR/match-arm-scopes.rs:14:34: 14:39 - let mut _0: i32; // return place in scope 0 at $DIR/match-arm-scopes.rs:14:66: 14:69 - let mut _3: &bool; // in scope 0 at $DIR/match-arm-scopes.rs:15:11: 15:16 - let mut _4: &bool; // in scope 0 at $DIR/match-arm-scopes.rs:15:11: 15:16 - let _5: bool; // in scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18 - let _6: &bool; // in scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18 - let _7: std::string::String; // in scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21 - let _8: &std::string::String; // in scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21 - let mut _9: bool; // in scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 - let mut _10: bool; // in scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49 - let mut _11: !; // in scope 0 at $DIR/match-arm-scopes.rs:16:52: 16:60 - let mut _12: bool; // in scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 - let mut _13: bool; // in scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49 - let mut _14: !; // in scope 0 at $DIR/match-arm-scopes.rs:16:52: 16:60 - let _15: bool; // in scope 0 at $DIR/match-arm-scopes.rs:17:16: 17:17 - let _16: std::string::String; // in scope 0 at $DIR/match-arm-scopes.rs:17:19: 17:20 - scope 1 { - debug a => _5; // in scope 1 at $DIR/match-arm-scopes.rs:16:17: 16:18 - debug a => _6; // in scope 1 at $DIR/match-arm-scopes.rs:16:17: 16:18 - debug s => _7; // in scope 1 at $DIR/match-arm-scopes.rs:16:20: 16:21 - debug s => _8; // in scope 1 at $DIR/match-arm-scopes.rs:16:20: 16:21 - } - scope 2 { - debug b => _15; // in scope 2 at $DIR/match-arm-scopes.rs:17:16: 17:17 - debug t => _16; // in scope 2 at $DIR/match-arm-scopes.rs:17:19: 17:20 - } - - bb0: { - switchInt((_2.0: bool)) -> [false: bb6, otherwise: bb2]; // scope 0 at $DIR/match-arm-scopes.rs:16:10: 16:15 - } - - bb1 (cleanup): { - resume; // scope 0 at $DIR/match-arm-scopes.rs:14:1: 19:2 - } - - bb2: { - switchInt((_2.1: bool)) -> [false: bb14, otherwise: bb3]; // scope 0 at $DIR/match-arm-scopes.rs:16:29: 16:34 - } - - bb3: { - switchInt((_2.0: bool)) -> [false: bb4, otherwise: bb21]; // scope 0 at $DIR/match-arm-scopes.rs:17:10: 17:14 - } - - bb4: { - StorageLive(_15); // scope 0 at $DIR/match-arm-scopes.rs:17:32: 17:33 - _15 = (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:17:32: 17:33 - StorageLive(_16); // scope 0 at $DIR/match-arm-scopes.rs:17:35: 17:36 - _16 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:17:35: 17:36 - goto -> bb20; // scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6 - } - - bb5: { - _0 = const 1_i32; // scope 1 at $DIR/match-arm-scopes.rs:16:77: 16:78 - // ty::Const - // + ty: i32 - // + val: Value(Scalar(0x00000001)) - // mir::Constant - // + span: $DIR/match-arm-scopes.rs:16:77: 16:78 - // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } - drop(_7) -> [return: bb19, unwind: bb10]; // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - } - - bb6: { - StorageLive(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18 - _6 = &(_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18 - StorageLive(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21 - _8 = &(_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21 - StorageLive(_9); // scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 - StorageLive(_10); // scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49 - _10 = _1; // scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49 - switchInt(_10) -> [false: bb7, otherwise: bb8]; // scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 - } - - bb7: { - _9 = (*_6); // scope 0 at $DIR/match-arm-scopes.rs:16:70: 16:71 - StorageDead(_10); // scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 - switchInt(move _9) -> [false: bb13, otherwise: bb12]; // scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 - } - - bb8: { - _0 = const 3_i32; // scope 0 at $DIR/match-arm-scopes.rs:16:59: 16:60 - // ty::Const - // + ty: i32 - // + val: Value(Scalar(0x00000003)) - // mir::Constant - // + span: $DIR/match-arm-scopes.rs:16:59: 16:60 - // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } - StorageDead(_10); // scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 - StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - goto -> bb11; // scope 0 at $DIR/match-arm-scopes.rs:16:52: 16:60 - } - - bb9: { - return; // scope 0 at $DIR/match-arm-scopes.rs:19:2: 19:2 - } - - bb10 (cleanup): { - goto -> bb25; // scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2 - } - - bb11: { - drop(_2) -> [return: bb9, unwind: bb1]; // scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2 - } - - bb12: { - StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - StorageLive(_5); // scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18 - _5 = (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18 - StorageLive(_7); // scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21 - _7 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21 - goto -> bb5; // scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6 - } - - bb13: { - StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - goto -> bb2; // scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 - } - - bb14: { - StorageLive(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:26: 16:27 - _6 = &(_2.0: bool); // scope 0 at $DIR/match-arm-scopes.rs:16:26: 16:27 - StorageLive(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:36: 16:37 - _8 = &(_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:16:36: 16:37 - StorageLive(_12); // scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 - StorageLive(_13); // scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49 - _13 = _1; // scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49 - switchInt(_13) -> [false: bb15, otherwise: bb16]; // scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 - } - - bb15: { - _12 = (*_6); // scope 0 at $DIR/match-arm-scopes.rs:16:70: 16:71 - StorageDead(_13); // scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 - switchInt(move _12) -> [false: bb18, otherwise: bb17]; // scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 - } - - bb16: { - _0 = const 3_i32; // scope 0 at $DIR/match-arm-scopes.rs:16:59: 16:60 - // ty::Const - // + ty: i32 - // + val: Value(Scalar(0x00000003)) - // mir::Constant - // + span: $DIR/match-arm-scopes.rs:16:59: 16:60 - // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } - StorageDead(_13); // scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 - StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - goto -> bb11; // scope 0 at $DIR/match-arm-scopes.rs:16:52: 16:60 - } - - bb17: { - StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - StorageLive(_5); // scope 0 at $DIR/match-arm-scopes.rs:16:26: 16:27 - _5 = (_2.0: bool); // scope 0 at $DIR/match-arm-scopes.rs:16:26: 16:27 - StorageLive(_7); // scope 0 at $DIR/match-arm-scopes.rs:16:36: 16:37 - _7 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:16:36: 16:37 - goto -> bb5; // scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6 - } - - bb18: { - StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - goto -> bb3; // scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 - } - - bb19: { - StorageDead(_7); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - StorageDead(_5); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - goto -> bb23; // scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6 - } - - bb20: { - _0 = const 2_i32; // scope 2 at $DIR/match-arm-scopes.rs:17:41: 17:42 - // ty::Const - // + ty: i32 - // + val: Value(Scalar(0x00000002)) - // mir::Constant - // + span: $DIR/match-arm-scopes.rs:17:41: 17:42 - // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } - drop(_16) -> [return: bb22, unwind: bb10]; // scope 0 at $DIR/match-arm-scopes.rs:17:41: 17:42 - } - - bb21: { - StorageLive(_15); // scope 0 at $DIR/match-arm-scopes.rs:17:16: 17:17 - _15 = (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:17:16: 17:17 - StorageLive(_16); // scope 0 at $DIR/match-arm-scopes.rs:17:19: 17:20 - _16 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:17:19: 17:20 - goto -> bb20; // scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6 - } - - bb22: { - StorageDead(_16); // scope 0 at $DIR/match-arm-scopes.rs:17:41: 17:42 - StorageDead(_15); // scope 0 at $DIR/match-arm-scopes.rs:17:41: 17:42 - goto -> bb23; // scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6 - } - - bb23: { - goto -> bb29; // scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2 - } - - bb24 (cleanup): { - goto -> bb1; // scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2 - } - - bb25 (cleanup): { - goto -> bb24; // scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2 - } - - bb26: { - goto -> bb9; // scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2 - } - - bb27 (cleanup): { - goto -> bb1; // scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2 - } - - bb28 (cleanup): { - goto -> bb27; // scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2 - } - - bb29: { - goto -> bb26; // scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2 - } -} diff --git a/src/test/mir-opt/match-arm-scopes/rustc.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff b/src/test/mir-opt/match-arm-scopes/rustc.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff new file mode 100644 index 0000000000000..58847e1bceee6 --- /dev/null +++ b/src/test/mir-opt/match-arm-scopes/rustc.complicated_match.SimplifyCfg-initial.after-ElaborateDrops.after.diff @@ -0,0 +1,313 @@ +- // MIR for `complicated_match` after SimplifyCfg-initial ++ // MIR for `complicated_match` after ElaborateDrops + + fn complicated_match(_1: bool, _2: (bool, bool, std::string::String)) -> i32 { + debug cond => _1; // in scope 0 at $DIR/match-arm-scopes.rs:13:22: 13:26 + debug items => _2; // in scope 0 at $DIR/match-arm-scopes.rs:13:34: 13:39 + let mut _0: i32; // return place in scope 0 at $DIR/match-arm-scopes.rs:13:66: 13:69 + let mut _3: &bool; // in scope 0 at $DIR/match-arm-scopes.rs:14:11: 14:16 + let mut _4: &bool; // in scope 0 at $DIR/match-arm-scopes.rs:14:11: 14:16 + let _5: bool; // in scope 0 at $DIR/match-arm-scopes.rs:15:17: 15:18 + let _6: &bool; // in scope 0 at $DIR/match-arm-scopes.rs:15:17: 15:18 + let _7: std::string::String; // in scope 0 at $DIR/match-arm-scopes.rs:15:20: 15:21 + let _8: &std::string::String; // in scope 0 at $DIR/match-arm-scopes.rs:15:20: 15:21 + let mut _9: bool; // in scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 + let mut _10: bool; // in scope 0 at $DIR/match-arm-scopes.rs:15:45: 15:49 + let mut _11: !; // in scope 0 at $DIR/match-arm-scopes.rs:15:52: 15:60 + let mut _12: bool; // in scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 + let mut _13: bool; // in scope 0 at $DIR/match-arm-scopes.rs:15:45: 15:49 + let mut _14: !; // in scope 0 at $DIR/match-arm-scopes.rs:15:52: 15:60 + let _15: bool; // in scope 0 at $DIR/match-arm-scopes.rs:16:16: 16:17 + let _16: std::string::String; // in scope 0 at $DIR/match-arm-scopes.rs:16:19: 16:20 + scope 1 { + debug a => _5; // in scope 1 at $DIR/match-arm-scopes.rs:15:17: 15:18 + debug a => _6; // in scope 1 at $DIR/match-arm-scopes.rs:15:17: 15:18 + debug s => _7; // in scope 1 at $DIR/match-arm-scopes.rs:15:20: 15:21 + debug s => _8; // in scope 1 at $DIR/match-arm-scopes.rs:15:20: 15:21 + } + scope 2 { + debug b => _15; // in scope 2 at $DIR/match-arm-scopes.rs:16:16: 16:17 + debug t => _16; // in scope 2 at $DIR/match-arm-scopes.rs:16:19: 16:20 + } + + bb0: { +- FakeRead(ForMatchedPlace, _2); // scope 0 at $DIR/match-arm-scopes.rs:14:11: 14:16 +- switchInt((_2.0: bool)) -> [false: bb2, otherwise: bb3]; // scope 0 at $DIR/match-arm-scopes.rs:15:10: 15:15 ++ switchInt((_2.0: bool)) -> [false: bb6, otherwise: bb2]; // scope 0 at $DIR/match-arm-scopes.rs:15:10: 15:15 + } + + bb1 (cleanup): { + resume; // scope 0 at $DIR/match-arm-scopes.rs:13:1: 18:2 + } + + bb2: { +- falseEdge -> [real: bb9, imaginary: bb4]; // scope 0 at $DIR/match-arm-scopes.rs:15:9: 15:22 ++ switchInt((_2.1: bool)) -> [false: bb14, otherwise: bb3]; // scope 0 at $DIR/match-arm-scopes.rs:15:29: 15:34 + } + + bb3: { +- switchInt((_2.1: bool)) -> [false: bb4, otherwise: bb5]; // scope 0 at $DIR/match-arm-scopes.rs:15:29: 15:34 ++ switchInt((_2.0: bool)) -> [false: bb4, otherwise: bb21]; // scope 0 at $DIR/match-arm-scopes.rs:16:10: 16:14 + } + + bb4: { +- falseEdge -> [real: bb18, imaginary: bb6]; // scope 0 at $DIR/match-arm-scopes.rs:15:25: 15:38 +- } +- +- bb5: { +- switchInt((_2.0: bool)) -> [false: bb7, otherwise: bb6]; // scope 0 at $DIR/match-arm-scopes.rs:16:10: 16:14 +- } +- +- bb6: { +- falseEdge -> [real: bb26, imaginary: bb7]; // scope 0 at $DIR/match-arm-scopes.rs:16:9: 16:21 +- } +- +- bb7: { + StorageLive(_15); // scope 0 at $DIR/match-arm-scopes.rs:16:32: 16:33 + _15 = (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:16:32: 16:33 + StorageLive(_16); // scope 0 at $DIR/match-arm-scopes.rs:16:35: 16:36 + _16 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:16:35: 16:36 +- goto -> bb25; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 ++ goto -> bb20; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 + } + +- bb8: { ++ bb5: { + _0 = const 1_i32; // scope 1 at $DIR/match-arm-scopes.rs:15:77: 15:78 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000001)) + // mir::Constant + // + span: $DIR/match-arm-scopes.rs:15:77: 15:78 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } +- drop(_7) -> [return: bb24, unwind: bb14]; // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 ++ drop(_7) -> [return: bb19, unwind: bb10]; // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 + } + +- bb9: { ++ bb6: { + StorageLive(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:17: 15:18 + _6 = &(_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:15:17: 15:18 + StorageLive(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:20: 15:21 + _8 = &(_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:15:20: 15:21 +- _3 = &shallow (_2.0: bool); // scope 0 at $DIR/match-arm-scopes.rs:14:11: 14:16 +- _4 = &shallow (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:14:11: 14:16 + StorageLive(_9); // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 + StorageLive(_10); // scope 0 at $DIR/match-arm-scopes.rs:15:45: 15:49 + _10 = _1; // scope 0 at $DIR/match-arm-scopes.rs:15:45: 15:49 +- FakeRead(ForMatchedPlace, _10); // scope 0 at $DIR/match-arm-scopes.rs:15:45: 15:49 +- switchInt(_10) -> [false: bb11, otherwise: bb10]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 ++ switchInt(_10) -> [false: bb7, otherwise: bb8]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 + } + +- bb10: { +- falseEdge -> [real: bb12, imaginary: bb11]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 +- } +- +- bb11: { ++ bb7: { + _9 = (*_6); // scope 0 at $DIR/match-arm-scopes.rs:15:70: 15:71 + StorageDead(_10); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 +- switchInt(move _9) -> [false: bb17, otherwise: bb16]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 ++ switchInt(move _9) -> [false: bb13, otherwise: bb12]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 + } + +- bb12: { ++ bb8: { + _0 = const 3_i32; // scope 0 at $DIR/match-arm-scopes.rs:15:59: 15:60 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/match-arm-scopes.rs:15:59: 15:60 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } + StorageDead(_10); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 + StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 + StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 + StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 +- goto -> bb15; // scope 0 at $DIR/match-arm-scopes.rs:15:52: 15:60 ++ goto -> bb11; // scope 0 at $DIR/match-arm-scopes.rs:15:52: 15:60 + } + +- bb13: { ++ bb9: { + return; // scope 0 at $DIR/match-arm-scopes.rs:18:2: 18:2 + } + +- bb14 (cleanup): { +- drop(_2) -> bb1; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2 ++ bb10 (cleanup): { ++ goto -> bb25; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2 + } + +- bb15: { +- drop(_2) -> [return: bb13, unwind: bb1]; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2 ++ bb11: { ++ drop(_2) -> [return: bb9, unwind: bb1]; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2 + } + +- bb16: { ++ bb12: { + StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 +- FakeRead(ForMatchGuard, _3); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 +- FakeRead(ForMatchGuard, _4); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 +- FakeRead(ForGuardBinding, _6); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 +- FakeRead(ForGuardBinding, _8); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 + StorageLive(_5); // scope 0 at $DIR/match-arm-scopes.rs:15:17: 15:18 + _5 = (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:15:17: 15:18 + StorageLive(_7); // scope 0 at $DIR/match-arm-scopes.rs:15:20: 15:21 + _7 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:15:20: 15:21 +- goto -> bb8; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 ++ goto -> bb5; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 + } + +- bb17: { ++ bb13: { + StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 + StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 + StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 +- falseEdge -> [real: bb3, imaginary: bb4]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 ++ goto -> bb2; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 + } + +- bb18: { ++ bb14: { + StorageLive(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:26: 15:27 + _6 = &(_2.0: bool); // scope 0 at $DIR/match-arm-scopes.rs:15:26: 15:27 + StorageLive(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:36: 15:37 + _8 = &(_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:15:36: 15:37 +- _3 = &shallow (_2.0: bool); // scope 0 at $DIR/match-arm-scopes.rs:14:11: 14:16 +- _4 = &shallow (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:14:11: 14:16 + StorageLive(_12); // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 + StorageLive(_13); // scope 0 at $DIR/match-arm-scopes.rs:15:45: 15:49 + _13 = _1; // scope 0 at $DIR/match-arm-scopes.rs:15:45: 15:49 +- FakeRead(ForMatchedPlace, _13); // scope 0 at $DIR/match-arm-scopes.rs:15:45: 15:49 +- switchInt(_13) -> [false: bb20, otherwise: bb19]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 ++ switchInt(_13) -> [false: bb15, otherwise: bb16]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 + } + +- bb19: { +- falseEdge -> [real: bb21, imaginary: bb20]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 +- } +- +- bb20: { ++ bb15: { + _12 = (*_6); // scope 0 at $DIR/match-arm-scopes.rs:15:70: 15:71 + StorageDead(_13); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 +- switchInt(move _12) -> [false: bb23, otherwise: bb22]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 ++ switchInt(move _12) -> [false: bb18, otherwise: bb17]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 + } + +- bb21: { ++ bb16: { + _0 = const 3_i32; // scope 0 at $DIR/match-arm-scopes.rs:15:59: 15:60 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000003)) + // mir::Constant + // + span: $DIR/match-arm-scopes.rs:15:59: 15:60 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } + StorageDead(_13); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 + StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 + StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 + StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 +- goto -> bb15; // scope 0 at $DIR/match-arm-scopes.rs:15:52: 15:60 ++ goto -> bb11; // scope 0 at $DIR/match-arm-scopes.rs:15:52: 15:60 + } + +- bb22: { ++ bb17: { + StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 +- FakeRead(ForMatchGuard, _3); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 +- FakeRead(ForMatchGuard, _4); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 +- FakeRead(ForGuardBinding, _6); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 +- FakeRead(ForGuardBinding, _8); // scope 0 at $DIR/match-arm-scopes.rs:15:72: 15:73 + StorageLive(_5); // scope 0 at $DIR/match-arm-scopes.rs:15:26: 15:27 + _5 = (_2.0: bool); // scope 0 at $DIR/match-arm-scopes.rs:15:26: 15:27 + StorageLive(_7); // scope 0 at $DIR/match-arm-scopes.rs:15:36: 15:37 + _7 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:15:36: 15:37 +- goto -> bb8; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 ++ goto -> bb5; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 + } + +- bb23: { ++ bb18: { + StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 + StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 + StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 +- falseEdge -> [real: bb5, imaginary: bb6]; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 ++ goto -> bb3; // scope 0 at $DIR/match-arm-scopes.rs:15:42: 15:73 + } + +- bb24: { ++ bb19: { + StorageDead(_7); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 + StorageDead(_5); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 + StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 + StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:15:77: 15:78 +- goto -> bb28; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 ++ goto -> bb23; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 + } + +- bb25: { ++ bb20: { + _0 = const 2_i32; // scope 2 at $DIR/match-arm-scopes.rs:16:41: 16:42 + // ty::Const + // + ty: i32 + // + val: Value(Scalar(0x00000002)) + // mir::Constant + // + span: $DIR/match-arm-scopes.rs:16:41: 16:42 + // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } +- drop(_16) -> [return: bb27, unwind: bb14]; // scope 0 at $DIR/match-arm-scopes.rs:16:41: 16:42 ++ drop(_16) -> [return: bb22, unwind: bb10]; // scope 0 at $DIR/match-arm-scopes.rs:16:41: 16:42 + } + +- bb26: { ++ bb21: { + StorageLive(_15); // scope 0 at $DIR/match-arm-scopes.rs:16:16: 16:17 + _15 = (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:16:16: 16:17 + StorageLive(_16); // scope 0 at $DIR/match-arm-scopes.rs:16:19: 16:20 + _16 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:16:19: 16:20 +- goto -> bb25; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 ++ goto -> bb20; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 + } + +- bb27: { ++ bb22: { + StorageDead(_16); // scope 0 at $DIR/match-arm-scopes.rs:16:41: 16:42 + StorageDead(_15); // scope 0 at $DIR/match-arm-scopes.rs:16:41: 16:42 +- goto -> bb28; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 ++ goto -> bb23; // scope 0 at $DIR/match-arm-scopes.rs:14:5: 17:6 + } + +- bb28: { +- drop(_2) -> [return: bb13, unwind: bb1]; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2 ++ bb23: { ++ goto -> bb29; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2 ++ } ++ ++ bb24 (cleanup): { ++ goto -> bb1; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2 ++ } ++ ++ bb25 (cleanup): { ++ goto -> bb24; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2 ++ } ++ ++ bb26: { ++ goto -> bb9; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2 ++ } ++ ++ bb27 (cleanup): { ++ goto -> bb1; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2 ++ } ++ ++ bb28 (cleanup): { ++ goto -> bb27; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2 ++ } ++ ++ bb29: { ++ goto -> bb26; // scope 0 at $DIR/match-arm-scopes.rs:18:1: 18:2 + } + } + diff --git a/src/test/mir-opt/match-arm-scopes/rustc.complicated_match.SimplifyCfg-initial.after.mir b/src/test/mir-opt/match-arm-scopes/rustc.complicated_match.SimplifyCfg-initial.after.mir deleted file mode 100644 index dadbc3668cb29..0000000000000 --- a/src/test/mir-opt/match-arm-scopes/rustc.complicated_match.SimplifyCfg-initial.after.mir +++ /dev/null @@ -1,246 +0,0 @@ -// MIR for `complicated_match` after SimplifyCfg-initial - -fn complicated_match(_1: bool, _2: (bool, bool, std::string::String)) -> i32 { - debug cond => _1; // in scope 0 at $DIR/match-arm-scopes.rs:14:22: 14:26 - debug items => _2; // in scope 0 at $DIR/match-arm-scopes.rs:14:34: 14:39 - let mut _0: i32; // return place in scope 0 at $DIR/match-arm-scopes.rs:14:66: 14:69 - let mut _3: &bool; // in scope 0 at $DIR/match-arm-scopes.rs:15:11: 15:16 - let mut _4: &bool; // in scope 0 at $DIR/match-arm-scopes.rs:15:11: 15:16 - let _5: bool; // in scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18 - let _6: &bool; // in scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18 - let _7: std::string::String; // in scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21 - let _8: &std::string::String; // in scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21 - let mut _9: bool; // in scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 - let mut _10: bool; // in scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49 - let mut _11: !; // in scope 0 at $DIR/match-arm-scopes.rs:16:52: 16:60 - let mut _12: bool; // in scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 - let mut _13: bool; // in scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49 - let mut _14: !; // in scope 0 at $DIR/match-arm-scopes.rs:16:52: 16:60 - let _15: bool; // in scope 0 at $DIR/match-arm-scopes.rs:17:16: 17:17 - let _16: std::string::String; // in scope 0 at $DIR/match-arm-scopes.rs:17:19: 17:20 - scope 1 { - debug a => _5; // in scope 1 at $DIR/match-arm-scopes.rs:16:17: 16:18 - debug a => _6; // in scope 1 at $DIR/match-arm-scopes.rs:16:17: 16:18 - debug s => _7; // in scope 1 at $DIR/match-arm-scopes.rs:16:20: 16:21 - debug s => _8; // in scope 1 at $DIR/match-arm-scopes.rs:16:20: 16:21 - } - scope 2 { - debug b => _15; // in scope 2 at $DIR/match-arm-scopes.rs:17:16: 17:17 - debug t => _16; // in scope 2 at $DIR/match-arm-scopes.rs:17:19: 17:20 - } - - bb0: { - FakeRead(ForMatchedPlace, _2); // scope 0 at $DIR/match-arm-scopes.rs:15:11: 15:16 - switchInt((_2.0: bool)) -> [false: bb2, otherwise: bb3]; // scope 0 at $DIR/match-arm-scopes.rs:16:10: 16:15 - } - - bb1 (cleanup): { - resume; // scope 0 at $DIR/match-arm-scopes.rs:14:1: 19:2 - } - - bb2: { - falseEdge -> [real: bb9, imaginary: bb4]; // scope 0 at $DIR/match-arm-scopes.rs:16:9: 16:22 - } - - bb3: { - switchInt((_2.1: bool)) -> [false: bb4, otherwise: bb5]; // scope 0 at $DIR/match-arm-scopes.rs:16:29: 16:34 - } - - bb4: { - falseEdge -> [real: bb18, imaginary: bb6]; // scope 0 at $DIR/match-arm-scopes.rs:16:25: 16:38 - } - - bb5: { - switchInt((_2.0: bool)) -> [false: bb7, otherwise: bb6]; // scope 0 at $DIR/match-arm-scopes.rs:17:10: 17:14 - } - - bb6: { - falseEdge -> [real: bb26, imaginary: bb7]; // scope 0 at $DIR/match-arm-scopes.rs:17:9: 17:21 - } - - bb7: { - StorageLive(_15); // scope 0 at $DIR/match-arm-scopes.rs:17:32: 17:33 - _15 = (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:17:32: 17:33 - StorageLive(_16); // scope 0 at $DIR/match-arm-scopes.rs:17:35: 17:36 - _16 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:17:35: 17:36 - goto -> bb25; // scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6 - } - - bb8: { - _0 = const 1_i32; // scope 1 at $DIR/match-arm-scopes.rs:16:77: 16:78 - // ty::Const - // + ty: i32 - // + val: Value(Scalar(0x00000001)) - // mir::Constant - // + span: $DIR/match-arm-scopes.rs:16:77: 16:78 - // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } - drop(_7) -> [return: bb24, unwind: bb14]; // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - } - - bb9: { - StorageLive(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18 - _6 = &(_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18 - StorageLive(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21 - _8 = &(_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21 - _3 = &shallow (_2.0: bool); // scope 0 at $DIR/match-arm-scopes.rs:15:11: 15:16 - _4 = &shallow (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:15:11: 15:16 - StorageLive(_9); // scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 - StorageLive(_10); // scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49 - _10 = _1; // scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49 - FakeRead(ForMatchedPlace, _10); // scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49 - switchInt(_10) -> [false: bb11, otherwise: bb10]; // scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 - } - - bb10: { - falseEdge -> [real: bb12, imaginary: bb11]; // scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 - } - - bb11: { - _9 = (*_6); // scope 0 at $DIR/match-arm-scopes.rs:16:70: 16:71 - StorageDead(_10); // scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 - switchInt(move _9) -> [false: bb17, otherwise: bb16]; // scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 - } - - bb12: { - _0 = const 3_i32; // scope 0 at $DIR/match-arm-scopes.rs:16:59: 16:60 - // ty::Const - // + ty: i32 - // + val: Value(Scalar(0x00000003)) - // mir::Constant - // + span: $DIR/match-arm-scopes.rs:16:59: 16:60 - // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } - StorageDead(_10); // scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 - StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - goto -> bb15; // scope 0 at $DIR/match-arm-scopes.rs:16:52: 16:60 - } - - bb13: { - return; // scope 0 at $DIR/match-arm-scopes.rs:19:2: 19:2 - } - - bb14 (cleanup): { - drop(_2) -> bb1; // scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2 - } - - bb15: { - drop(_2) -> [return: bb13, unwind: bb1]; // scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2 - } - - bb16: { - StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - FakeRead(ForMatchGuard, _3); // scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 - FakeRead(ForMatchGuard, _4); // scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 - FakeRead(ForGuardBinding, _6); // scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 - FakeRead(ForGuardBinding, _8); // scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 - StorageLive(_5); // scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18 - _5 = (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:16:17: 16:18 - StorageLive(_7); // scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21 - _7 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:16:20: 16:21 - goto -> bb8; // scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6 - } - - bb17: { - StorageDead(_9); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - falseEdge -> [real: bb3, imaginary: bb4]; // scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 - } - - bb18: { - StorageLive(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:26: 16:27 - _6 = &(_2.0: bool); // scope 0 at $DIR/match-arm-scopes.rs:16:26: 16:27 - StorageLive(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:36: 16:37 - _8 = &(_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:16:36: 16:37 - _3 = &shallow (_2.0: bool); // scope 0 at $DIR/match-arm-scopes.rs:15:11: 15:16 - _4 = &shallow (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:15:11: 15:16 - StorageLive(_12); // scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 - StorageLive(_13); // scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49 - _13 = _1; // scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49 - FakeRead(ForMatchedPlace, _13); // scope 0 at $DIR/match-arm-scopes.rs:16:45: 16:49 - switchInt(_13) -> [false: bb20, otherwise: bb19]; // scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 - } - - bb19: { - falseEdge -> [real: bb21, imaginary: bb20]; // scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 - } - - bb20: { - _12 = (*_6); // scope 0 at $DIR/match-arm-scopes.rs:16:70: 16:71 - StorageDead(_13); // scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 - switchInt(move _12) -> [false: bb23, otherwise: bb22]; // scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 - } - - bb21: { - _0 = const 3_i32; // scope 0 at $DIR/match-arm-scopes.rs:16:59: 16:60 - // ty::Const - // + ty: i32 - // + val: Value(Scalar(0x00000003)) - // mir::Constant - // + span: $DIR/match-arm-scopes.rs:16:59: 16:60 - // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } - StorageDead(_13); // scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 - StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - goto -> bb15; // scope 0 at $DIR/match-arm-scopes.rs:16:52: 16:60 - } - - bb22: { - StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - FakeRead(ForMatchGuard, _3); // scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 - FakeRead(ForMatchGuard, _4); // scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 - FakeRead(ForGuardBinding, _6); // scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 - FakeRead(ForGuardBinding, _8); // scope 0 at $DIR/match-arm-scopes.rs:16:72: 16:73 - StorageLive(_5); // scope 0 at $DIR/match-arm-scopes.rs:16:26: 16:27 - _5 = (_2.0: bool); // scope 0 at $DIR/match-arm-scopes.rs:16:26: 16:27 - StorageLive(_7); // scope 0 at $DIR/match-arm-scopes.rs:16:36: 16:37 - _7 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:16:36: 16:37 - goto -> bb8; // scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6 - } - - bb23: { - StorageDead(_12); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - falseEdge -> [real: bb5, imaginary: bb6]; // scope 0 at $DIR/match-arm-scopes.rs:16:42: 16:73 - } - - bb24: { - StorageDead(_7); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - StorageDead(_5); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - StorageDead(_8); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - StorageDead(_6); // scope 0 at $DIR/match-arm-scopes.rs:16:77: 16:78 - goto -> bb28; // scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6 - } - - bb25: { - _0 = const 2_i32; // scope 2 at $DIR/match-arm-scopes.rs:17:41: 17:42 - // ty::Const - // + ty: i32 - // + val: Value(Scalar(0x00000002)) - // mir::Constant - // + span: $DIR/match-arm-scopes.rs:17:41: 17:42 - // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } - drop(_16) -> [return: bb27, unwind: bb14]; // scope 0 at $DIR/match-arm-scopes.rs:17:41: 17:42 - } - - bb26: { - StorageLive(_15); // scope 0 at $DIR/match-arm-scopes.rs:17:16: 17:17 - _15 = (_2.1: bool); // scope 0 at $DIR/match-arm-scopes.rs:17:16: 17:17 - StorageLive(_16); // scope 0 at $DIR/match-arm-scopes.rs:17:19: 17:20 - _16 = move (_2.2: std::string::String); // scope 0 at $DIR/match-arm-scopes.rs:17:19: 17:20 - goto -> bb25; // scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6 - } - - bb27: { - StorageDead(_16); // scope 0 at $DIR/match-arm-scopes.rs:17:41: 17:42 - StorageDead(_15); // scope 0 at $DIR/match-arm-scopes.rs:17:41: 17:42 - goto -> bb28; // scope 0 at $DIR/match-arm-scopes.rs:15:5: 18:6 - } - - bb28: { - drop(_2) -> [return: bb13, unwind: bb1]; // scope 0 at $DIR/match-arm-scopes.rs:19:1: 19:2 - } -} diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index f09f7621aa170..21fb7673ce061 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -3135,14 +3135,47 @@ impl<'test> TestCx<'test> { } for l in test_file_contents.lines() { if l.starts_with("// EMIT_MIR ") { - let test_name = l.trim_start_matches("// EMIT_MIR "); - let expected_file = test_dir.join(test_name); - - let dumped_string = if test_name.ends_with(".diff") { - let test_name = test_name.trim_end_matches(".diff"); - let before = format!("{}.before.mir", test_name); - let after = format!("{}.after.mir", test_name); - let before = self.get_mir_dump_dir().join(before); + let test_name = l.trim_start_matches("// EMIT_MIR ").trim(); + let mut test_names = test_name.split(' '); + // sometimes we specify two files so that we get a diff between the two files + let test_name = test_names.next().unwrap(); + let expected_file; + let from_file; + let to_file; + + if test_name.ends_with(".diff") { + let trimmed = test_name.trim_end_matches(".diff"); + let test_against = format!("{}.after.mir", trimmed); + from_file = format!("{}.before.mir", trimmed); + expected_file = test_name.to_string(); + assert!( + test_names.next().is_none(), + "two mir pass names specified for MIR diff" + ); + to_file = Some(test_against); + } else if let Some(first_pass) = test_names.next() { + let second_pass = test_names.next().unwrap(); + assert!( + test_names.next().is_none(), + "three mir pass names specified for MIR diff" + ); + expected_file = format!("{}.{}-{}.diff", test_name, first_pass, second_pass); + let second_file = format!("{}.{}.mir", test_name, second_pass); + from_file = format!("{}.{}.mir", test_name, first_pass); + to_file = Some(second_file); + } else { + expected_file = test_name.to_string(); + from_file = test_name.to_string(); + assert!( + test_names.next().is_none(), + "two mir pass names specified for MIR dump" + ); + to_file = None; + }; + let expected_file = test_dir.join(expected_file); + + let dumped_string = if let Some(after) = to_file { + let before = self.get_mir_dump_dir().join(from_file); let after = self.get_mir_dump_dir().join(after); debug!( "comparing the contents of: {} with {}", @@ -3166,7 +3199,7 @@ impl<'test> TestCx<'test> { } else { let mut output_file = PathBuf::new(); output_file.push(self.get_mir_dump_dir()); - output_file.push(test_name); + output_file.push(&from_file); debug!( "comparing the contents of: {} with {}", output_file.display(), @@ -3179,7 +3212,7 @@ impl<'test> TestCx<'test> { output_file.parent().unwrap().display() ); } - self.check_mir_test_timestamp(test_name, &output_file); + self.check_mir_test_timestamp(&from_file, &output_file); let dumped_string = fs::read_to_string(&output_file).unwrap(); self.normalize_output(&dumped_string, &[]) };