From d63f10b7addc4f5c5528b76cedb41433a275eed3 Mon Sep 17 00:00:00 2001 From: sfzhu93 Date: Thu, 11 Jan 2024 23:22:33 -0800 Subject: [PATCH] resolve code reviews --- .../dataflow-const-prop/array_index.rs | 7 +-- .../dataflow-const-prop/boolean_identities.rs | 4 ++ tests/mir-opt/dataflow-const-prop/checked.rs | 2 + .../default_boxed_slice.rs | 5 +- tests/mir-opt/dataflow-const-prop/enum.rs | 23 ++++---- tests/mir-opt/dataflow-const-prop/if.rs | 6 +-- .../dataflow-const-prop/issue_81605.rs | 10 +++- .../dataflow-const-prop/large_array_index.rs | 2 +- .../dataflow-const-prop/mult_by_zero.rs | 2 +- .../mir-opt/dataflow-const-prop/offset_of.rs | 20 +++---- .../dataflow-const-prop/ref_without_sb.rs | 8 +-- tests/mir-opt/dataflow-const-prop/repeat.rs | 14 +++-- .../dataflow-const-prop/repr_transparent.rs | 2 +- .../dataflow-const-prop/self_assign.rs | 10 ++-- .../dataflow-const-prop/self_assign_add.rs | 2 +- .../dataflow-const-prop/sibling_ptr.rs | 6 +-- .../mir-opt/dataflow-const-prop/slice_len.rs | 25 ++++++--- tests/mir-opt/dataflow-const-prop/struct.rs | 52 +++++++++---------- .../mir-opt/dataflow-const-prop/terminator.rs | 4 +- tests/mir-opt/dataflow-const-prop/tuple.rs | 10 ++-- 20 files changed, 118 insertions(+), 96 deletions(-) diff --git a/tests/mir-opt/dataflow-const-prop/array_index.rs b/tests/mir-opt/dataflow-const-prop/array_index.rs index 42c99df969e..4b070e1d6d6 100644 --- a/tests/mir-opt/dataflow-const-prop/array_index.rs +++ b/tests/mir-opt/dataflow-const-prop/array_index.rs @@ -10,10 +10,7 @@ fn main() { // CHECK: debug x => [[x:_.*]]; let x: u32 = [0, 1, 2, 3][2]; - // CHECK: bb{{[0-9]+}}: { - // CHECK: [[array_lit]] = [const 0_u32, const 1_u32, const 2_u32, const 3_u32]; - // CHECK: [[index:_.*]] = const 2_usize; - // CHECK: bb{{[0-9]+}}: { - // CHECK-NOT: [[x]] = [[array_lit]][[[index]]]; + // CHECK: [[array_lit]] = [const 0_u32, const 1_u32, const 2_u32, const 3_u32]; + // CHECK-LABEL: assert(const true, // CHECK: [[x]] = [[array_lit]][2 of 3]; } diff --git a/tests/mir-opt/dataflow-const-prop/boolean_identities.rs b/tests/mir-opt/dataflow-const-prop/boolean_identities.rs index 93e9b8d52fc..c9be1d65b03 100644 --- a/tests/mir-opt/dataflow-const-prop/boolean_identities.rs +++ b/tests/mir-opt/dataflow-const-prop/boolean_identities.rs @@ -4,8 +4,12 @@ // CHECK-LABEL: fn test( pub fn test(x: bool, y: bool) -> bool { + // CHECK-NOT: BitAnd( + // CHECK-NOT: BitOr( (y | true) & (x & false) // CHECK: _0 = const false; + // CHECK-NOT: BitAnd( + // CHECK-NOT: BitOr( } // CHECK-LABEL: fn main( diff --git a/tests/mir-opt/dataflow-const-prop/checked.rs b/tests/mir-opt/dataflow-const-prop/checked.rs index 7350e5fb3d8..45331f91323 100644 --- a/tests/mir-opt/dataflow-const-prop/checked.rs +++ b/tests/mir-opt/dataflow-const-prop/checked.rs @@ -19,12 +19,14 @@ fn main() { // CHECK: [[b]] = const 2_i32; let b = 2; + // CHECK-LABEL: assert(!const false, // CHECK: [[c]] = const 3_i32; let c = a + b; // CHECK: [[d]] = const _; let d = i32::MAX; + // CHECK-LABEL: assert(!const true, // CHECK: [[e]] = const i32::MIN; let e = d + 1; } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs index 59174034503..b15809f2510 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs @@ -17,13 +17,10 @@ fn main() { // Verify that `DataflowConstProp` does not ICE trying to dereference it directly. // CHECK: debug a => [[a:_.*]]; - // CHECK: scope {{[0-9]+}} (inlined as Default>::default) { - // CHECK: scope {{[0-9]+}} (inlined Unique::<[bool; 0]>::dangling) { - // CHECK: scope {{[0-9]+}} (inlined NonNull::<[bool; 0]>::dangling) { // We may check other inlined functions as well... - // CHECK: bb{{[0-9]+}}: { // CHECK: [[box_obj:_.*]] = Box::<[bool]>(_3, const std::alloc::Global); // CHECK: [[a]] = A { foo: move [[box_obj]] }; + // FIXME: we do not have `const Box::<[bool]>` after constprop right now. let a: A = A { foo: Box::default() }; } diff --git a/tests/mir-opt/dataflow-const-prop/enum.rs b/tests/mir-opt/dataflow-const-prop/enum.rs index f33e4240344..26fdda2664a 100644 --- a/tests/mir-opt/dataflow-const-prop/enum.rs +++ b/tests/mir-opt/dataflow-const-prop/enum.rs @@ -20,8 +20,8 @@ fn simple() { // CHECK: [[e]] = const E::V1(0_i32); let e = E::V1(0); - // CHECK: switchInt(const 0_isize) -> [0: bb[[target_bb:[0-9]+]], 1: bb1, otherwise: bb2]; - // CHECK: bb[[target_bb]]: { + // CHECK: switchInt(const 0_isize) -> [0: [[target_bb:bb.*]], 1: bb1, otherwise: bb2]; + // CHECK: [[target_bb]]: { // CHECK: [[x]] = const 0_i32; let x = match e { E::V1(x1) => x1, E::V2(x2) => x2 }; } @@ -36,8 +36,8 @@ fn constant() { // CHECK: [[e]] = const _; let e = C; - // CHECK: switchInt(const 0_isize) -> [0: bb[[target_bb:[0-9]+]], 1: bb1, otherwise: bb2]; - // CHECK: bb[[target_bb]]: { + // CHECK: switchInt(const 0_isize) -> [0: [[target_bb:bb.*]], 1: bb1, otherwise: bb2]; + // CHECK: [[target_bb]]: { // CHECK: [[x]] = const 0_i32; let x = match e { E::V1(x1) => x1, E::V2(x2) => x2 }; } @@ -55,8 +55,8 @@ fn statics() { // CHECK: [[e1]] = const E::V1(0_i32); let e1 = C; - // CHECK: switchInt(const 0_isize) -> [0: bb[[target_bb1:[0-9]+]], 1: bb1, otherwise: bb2]; - // CHECK: bb[[target_bb]]: { + // CHECK: switchInt(const 0_isize) -> [0: [[target_bb:bb.*]], 1: bb1, otherwise: bb2]; + // CHECK: [[target_bb]]: { // CHECK: [[x1]] = const 0_i32; let x1 = match e1 { E::V1(x11) => x11, E::V2(x12) => x12 }; @@ -65,7 +65,8 @@ fn statics() { // CHECK: [[t:_.*]] = const {alloc2: &&E}; // CHECK: [[e2]] = (*[[t]]); let e2 = RC; - // CHECK: switchInt(move _{{[0-9]+}}) -> [0: bb{{[0-9]+}}, 1: bb{{[0-9]+}}, otherwise: bb{{[0-9]+}}]; + + // CHECK: switchInt({{move _.*}}) -> {{.*}} // FIXME: add checks for x2. Currently, their MIRs are not symmetric in the two // switch branches. // One is `_9 = &(*_12) and another is `_9 = _11`. It is different from what we can @@ -91,10 +92,10 @@ fn mutate_discriminant() -> u8 { place!(Field(Field(Variant(x, 1), 0), 0)) = 0_usize; // So we cannot know the value of this discriminant. - // CHECK: [[a:_.*]] = discriminant(_{{[0-9]*}}); + // CHECK: [[a:_.*]] = discriminant({{_.*}}); let a = Discriminant(x); - // CHECK: switchInt([[a]]) -> [0: bb{{[0-9]+}}, otherwise: bb{{[0-9]+}}]; + // CHECK: switchInt([[a]]) -> [0: {{bb.*}}, otherwise: {{bb.*}}]; match a { 0 => bb1, _ => bad, @@ -118,7 +119,7 @@ fn multiple(x: bool, i: u8) { // CHECK: debug e => [[e:_.*]]; // CHECK: debug x2 => [[x2:_.*]]; let e = if x { - // CHECK: [[e]] = Option::::Some(move _{{[0-9]+}}); + // CHECK: [[e]] = Option::::Some(move {{_.*}}); Some(i) } else { // CHECK: [[e]] = Option::::None; @@ -128,7 +129,7 @@ fn multiple(x: bool, i: u8) { // discriminant(e) => Top // (e as Some).0 => Top // CHECK: [[x2]] = const 0_u8; - // CHECK: [[x2]] = _{{[0-9]+}} + // CHECK: [[x2]] = {{_.*}}; let x2 = match e { Some(i) => i, None => 0 }; // Therefore, `x2` should be `Top` here, and no replacement shall happen. let y = x2; diff --git a/tests/mir-opt/dataflow-const-prop/if.rs b/tests/mir-opt/dataflow-const-prop/if.rs index 28e0ee9c622..3400068baba 100644 --- a/tests/mir-opt/dataflow-const-prop/if.rs +++ b/tests/mir-opt/dataflow-const-prop/if.rs @@ -10,16 +10,14 @@ fn main() { let a = 1; - // CHECK: switchInt(const true) -> [0: {{bb[0-9]+}}, otherwise: [[bb_first_true:bb[0-9]+]]]; - // CHECK: [[bb_first_true]]: { + // CHECK: switchInt(const true) -> [0: {{bb.*}}, otherwise: {{bb.*}}]; // CHECK: [[b]] = const 2_i32; let b = if a == 1 { 2 } else { 3 }; // CHECK: [[c]] = const 3_i32; let c = b + 1; - // CHECK: switchInt(const true) -> [0: {{bb[0-9]+}}, otherwise: [[bb_second_true:bb[0-9]+]]]; - // CHECK: [[bb_second_true]]: { + // CHECK: switchInt(const true) -> [0: {{bb.*}}, otherwise: {{bb.*}}]; // CHECK: [[d]] = const 1_i32; let d = if a == 1 { a } else { a + 1 }; diff --git a/tests/mir-opt/dataflow-const-prop/issue_81605.rs b/tests/mir-opt/dataflow-const-prop/issue_81605.rs index e8a00c72eb6..f13c364279d 100644 --- a/tests/mir-opt/dataflow-const-prop/issue_81605.rs +++ b/tests/mir-opt/dataflow-const-prop/issue_81605.rs @@ -2,9 +2,15 @@ // EMIT_MIR issue_81605.f.DataflowConstProp.diff -// CHECK-LABEL: fn f +// Plese find the original issue [here](https://github.com/rust-lang/rust/issues/81605). +// This test program comes directly from the issue. Prior to this issue, +// the compiler cannot simplify the return value of `f` into 2. This was +// solved by adding a new MIR constant propagation based on dataflow +// analysis in [#101168](https://github.com/rust-lang/rust/pull/101168). + +// CHECK-LABEL: fn f( fn f() -> usize { - // CHECK: switchInt(const true) -> [0: {{bb[0-9]+}}, otherwise: {{bb[0-9]+}}]; + // CHECK: switchInt(const true) -> [0: {{bb.*}}, otherwise: {{bb.*}}]; 1 + if true { 1 } else { 2 } // CHECK: _0 = const 2_usize; } diff --git a/tests/mir-opt/dataflow-const-prop/large_array_index.rs b/tests/mir-opt/dataflow-const-prop/large_array_index.rs index 6b8a0248d19..fbca411e204 100644 --- a/tests/mir-opt/dataflow-const-prop/large_array_index.rs +++ b/tests/mir-opt/dataflow-const-prop/large_array_index.rs @@ -4,7 +4,7 @@ // EMIT_MIR large_array_index.main.DataflowConstProp.diff -// CHECK-LABEL: fn main +// CHECK-LABEL: fn main( fn main() { // check that we don't propagate this, because it's too large diff --git a/tests/mir-opt/dataflow-const-prop/mult_by_zero.rs b/tests/mir-opt/dataflow-const-prop/mult_by_zero.rs index c7e05579e40..be8ce731056 100644 --- a/tests/mir-opt/dataflow-const-prop/mult_by_zero.rs +++ b/tests/mir-opt/dataflow-const-prop/mult_by_zero.rs @@ -1,7 +1,7 @@ // unit-test: DataflowConstProp // EMIT_MIR mult_by_zero.test.DataflowConstProp.diff -// CHECK-LABEL: fn test +// CHECK-LABEL: fn test( fn test(x : i32) -> i32 { x * 0 // CHECK: _0 = const 0_i32; diff --git a/tests/mir-opt/dataflow-const-prop/offset_of.rs b/tests/mir-opt/dataflow-const-prop/offset_of.rs index a2032ea996e..ff9fe7f2fbd 100644 --- a/tests/mir-opt/dataflow-const-prop/offset_of.rs +++ b/tests/mir-opt/dataflow-const-prop/offset_of.rs @@ -29,45 +29,45 @@ struct Delta { // EMIT_MIR offset_of.concrete.DataflowConstProp.diff -// CHECK-LABEL: fn concrete +// CHECK-LABEL: fn concrete( fn concrete() { // CHECK: debug x => [[x:_.*]]; // CHECK: debug y => [[y:_.*]]; // CHECK: debug z0 => [[z0:_.*]]; // CHECK: debug z1 => [[z1:_.*]]; - // CHECK: [[x]] = must_use::(const 4_usize) -> [return: {{bb[0-9]+}}, unwind continue]; + // CHECK: [[x]] = must_use::(const 4_usize) -> {{.*}} let x = offset_of!(Alpha, x); - // CHECK: [[y]] = must_use::(const 0_usize) -> [return: {{bb[0-9]+}}, unwind continue]; + // CHECK: [[y]] = must_use::(const 0_usize) -> {{.*}} let y = offset_of!(Alpha, y); - // CHECK: [[z0]] = must_use::(const 2_usize) -> [return: {{bb[0-9]+}}, unwind continue]; + // CHECK: [[z0]] = must_use::(const 2_usize) -> {{.*}} let z0 = offset_of!(Alpha, z.0); - // CHECK: [[z1]] = must_use::(const 3_usize) -> [return: {{bb[0-9]+}}, unwind continue]; + // CHECK: [[z1]] = must_use::(const 3_usize) -> {{.*}} let z1 = offset_of!(Alpha, z.1); } // EMIT_MIR offset_of.generic.DataflowConstProp.diff -// CHECK-LABEL: generic +// CHECK-LABEL: fn generic( fn generic() { // CHECK: debug gx => [[gx:_.*]]; // CHECK: debug gy => [[gy:_.*]]; // CHECK: debug dx => [[dx:_.*]]; // CHECK: debug dy => [[dy:_.*]]; - // CHECK: [[gx]] = must_use::(move {{_[0-9]+}}) -> [return: {{bb[0-9]+}}, unwind continue]; + // CHECK: [[gx]] = must_use::(move {{_.*}}) -> {{.*}} let gx = offset_of!(Gamma, x); - // CHECK: [[gy]] = must_use::(move {{_[0-9]+}}) -> [return: {{bb[0-9]+}}, unwind continue]; + // CHECK: [[gy]] = must_use::(move {{_.*}}) -> {{.*}} let gy = offset_of!(Gamma, y); - // CHECK: [[dx]] = must_use::(const 0_usize) -> [return: {{bb[0-9]+}}, unwind continue]; + // CHECK: [[dx]] = must_use::(const 0_usize) -> {{.*}} let dx = offset_of!(Delta, x); - // CHECK: [[dy]] = must_use::(const 2_usize) -> [return: {{bb[0-9]+}}, unwind continue]; + // CHECK: [[dy]] = must_use::(const 2_usize) -> {{.*}} let dy = offset_of!(Delta, y); } diff --git a/tests/mir-opt/dataflow-const-prop/ref_without_sb.rs b/tests/mir-opt/dataflow-const-prop/ref_without_sb.rs index fb66cda38dd..7bf2b184078 100644 --- a/tests/mir-opt/dataflow-const-prop/ref_without_sb.rs +++ b/tests/mir-opt/dataflow-const-prop/ref_without_sb.rs @@ -8,21 +8,23 @@ fn escape(x: &T) {} fn some_function() {} // EMIT_MIR ref_without_sb.main.DataflowConstProp.diff -// CHECK-LABEL: fn main +// CHECK-LABEL: fn main( fn main() { // CHECK: debug a => [[a:_.*]]; // CHECK: debug b => [[b:_.*]]; let mut a = 0; - // CHECK: {{_[0-9]+}} = escape::(move {{_[0-9]+}}) -> [return: {{bb[0-9]+}}, unwind continue]; + // CHECK: {{_.*}} = escape::(move {{_.*}}) -> {{.*}} escape(&a); a = 1; - // CHECK: {{_[0-9]+}} = some_function() -> [return: {{bb[0-9]+}}, unwind continue]; + // CHECK: {{_.*}} = some_function() -> {{.*}} some_function(); // This should currently not be propagated. + // CHECK-NOT: [[b]] = const // CHECK: [[b]] = [[a]]; + // CHECK-NOT: [[b]] = const let b = a; } diff --git a/tests/mir-opt/dataflow-const-prop/repeat.rs b/tests/mir-opt/dataflow-const-prop/repeat.rs index 5d1c1a3edb6..80eb14dedea 100644 --- a/tests/mir-opt/dataflow-const-prop/repeat.rs +++ b/tests/mir-opt/dataflow-const-prop/repeat.rs @@ -3,15 +3,19 @@ // EMIT_MIR_FOR_EACH_BIT_WIDTH // EMIT_MIR repeat.main.DataflowConstProp.diff -// CHECK-LABEL: fn main +// CHECK-LABEL: fn main( fn main() { // CHECK: debug x => [[x:_.*]]; - // CHECK: {{_[0-9]+}} = const 8_usize; - // CHECK: {{_[0-9]+}} = const true; + // CHECK: [[array_lit:_.*]] = [const 42_u32; 8]; + // CHECK-NOT: {{_.*}} = Len( + // CHECK-NOT: {{_.*}} = Lt( + // CHECK: {{_.*}} = const 8_usize; + // CHECK: {{_.*}} = const true; // CHECK-LABEL: assert(const true - // CHECK: {{_[0-9]+}} = {{_[0-9]+}}[2 of 3]; - // CHECK: [[x]] = Add(move {{_[0-9]+}}, const 0_u32); + // CHECK-NOT: [[t:_.*]] = [[array_lit]][_ + // CHECK: [[t:_.*]] = [[array_lit]][2 of 3]; + // CHECK: [[x]] = Add(move [[t]], const 0_u32); let x: u32 = [42; 8][2] + 0; } diff --git a/tests/mir-opt/dataflow-const-prop/repr_transparent.rs b/tests/mir-opt/dataflow-const-prop/repr_transparent.rs index d007301e568..39a2b357193 100644 --- a/tests/mir-opt/dataflow-const-prop/repr_transparent.rs +++ b/tests/mir-opt/dataflow-const-prop/repr_transparent.rs @@ -7,7 +7,7 @@ struct I32(i32); // EMIT_MIR repr_transparent.main.DataflowConstProp.diff -// CHECK-LABEL: fn main +// CHECK-LABEL: fn main( fn main() { // CHECK: debug x => [[x:_.*]]; // CHECK: debug y => [[y:_.*]]; diff --git a/tests/mir-opt/dataflow-const-prop/self_assign.rs b/tests/mir-opt/dataflow-const-prop/self_assign.rs index 7d58b972d65..a5b23213128 100644 --- a/tests/mir-opt/dataflow-const-prop/self_assign.rs +++ b/tests/mir-opt/dataflow-const-prop/self_assign.rs @@ -2,25 +2,25 @@ // EMIT_MIR self_assign.main.DataflowConstProp.diff -// CHECK-LABEL: fn main +// CHECK-LABEL: fn main( fn main() { // CHECK: debug a => [[a:_.*]]; // CHECK: debug b => [[b:_.*]]; let mut a = 0; - // CHECK: [[a]] = Add(move {{_[0-9]+}}, const 1_i32); + // CHECK: [[a]] = Add(move {{_.*}}, const 1_i32); a = a + 1; - // CHECK: [[a]] = move {{_[0-9]+}}; + // CHECK: [[a]] = move {{_.*}}; a = a; // CHECK: [[b]] = &[[a]]; let mut b = &a; - // CHECK: [[b]] = move {{_[0-9]+}}; + // CHECK: [[b]] = move {{_.*}}; b = b; - // CHECK: [[a]] = move {{_[0-9]+}}; + // CHECK: [[a]] = move {{_.*}}; a = *b; } diff --git a/tests/mir-opt/dataflow-const-prop/self_assign_add.rs b/tests/mir-opt/dataflow-const-prop/self_assign_add.rs index 09be3865d60..7bfbda7a96c 100644 --- a/tests/mir-opt/dataflow-const-prop/self_assign_add.rs +++ b/tests/mir-opt/dataflow-const-prop/self_assign_add.rs @@ -2,7 +2,7 @@ // EMIT_MIR self_assign_add.main.DataflowConstProp.diff -// CHECK-LABEL: fn main +// CHECK-LABEL: fn main( fn main() { // CHECK: debug a => [[a:_.*]]; let mut a = 0; diff --git a/tests/mir-opt/dataflow-const-prop/sibling_ptr.rs b/tests/mir-opt/dataflow-const-prop/sibling_ptr.rs index 6e39e398394..9c610aabe82 100644 --- a/tests/mir-opt/dataflow-const-prop/sibling_ptr.rs +++ b/tests/mir-opt/dataflow-const-prop/sibling_ptr.rs @@ -10,9 +10,9 @@ // EMIT_MIR sibling_ptr.main.DataflowConstProp.diff -// CHECK-LABEL: fn main +// CHECK-LABEL: fn main( fn main() { - // CHECK: debug x1 => [[x1:_[0-9]+]]; + // CHECK: debug x1 => [[x1:_.*]]; let mut x: (u8, u8) = (0, 0); unsafe { @@ -20,6 +20,6 @@ fn main() { *p.add(1) = 1; } - // CHECK: [[x1]] = ({{_[0-9]+}}.1: u8); + // CHECK: [[x1]] = ({{_.*}}.1: u8); let x1 = x.1; // should not be propagated } diff --git a/tests/mir-opt/dataflow-const-prop/slice_len.rs b/tests/mir-opt/dataflow-const-prop/slice_len.rs index cd639809496..65c87580330 100644 --- a/tests/mir-opt/dataflow-const-prop/slice_len.rs +++ b/tests/mir-opt/dataflow-const-prop/slice_len.rs @@ -5,19 +5,30 @@ // EMIT_MIR slice_len.main.DataflowConstProp.diff -// CHECK-LABEL: fn main +// CHECK-LABEL: fn main( fn main() { - // CHECK: debug local => [[local:_[0-9]+]]; - // CHECK: debug constant => [[constant:_[0-9]+]]; + // CHECK: debug local => [[local:_.*]]; + // CHECK: debug constant => [[constant:_.*]]; - // CHECK: {{_[0-9]+}} = const 3_usize; - // CHECK: {{_[0-9]+}} = const true; + // CHECK-NOT: {{_.*}} = Len( + // CHECK-NOT: {{_.*}} = Lt( + // CHECK-NOT: assert(move _ + // CHECK: {{_.*}} = const 3_usize; + // CHECK: {{_.*}} = const true; + // CHECK: assert(const true, - // CHECK: [[local]] = (*{{_[0-9]+}})[1 of 2]; + // CHECK: [[local]] = (*{{_.*}})[1 of 2]; let local = (&[1u32, 2, 3] as &[u32])[1]; + // CHECK-NOT: {{_.*}} = Len( + // CHECK-NOT: {{_.*}} = Lt( + // CHECK-NOT: assert(move _ const SLICE: &[u32] = &[1, 2, 3]; + // CHECK: {{_.*}} = const 3_usize; + // CHECK: {{_.*}} = const true; + // CHECK: assert(const true, - // CHECK: [[constant]] = (*{{_[0-9]+}})[1 of 2]; + // CHECK-NOT: [[constant]] = (*{{_.*}})[_ + // CHECK: [[constant]] = (*{{_.*}})[1 of 2]; let constant = SLICE[1]; } diff --git a/tests/mir-opt/dataflow-const-prop/struct.rs b/tests/mir-opt/dataflow-const-prop/struct.rs index 4eec15a7f16..a7e0f6a987d 100644 --- a/tests/mir-opt/dataflow-const-prop/struct.rs +++ b/tests/mir-opt/dataflow-const-prop/struct.rs @@ -12,25 +12,25 @@ struct BigStruct(f32, Option, &'static [f32]); // EMIT_MIR struct.main.DataflowConstProp.diff -// CHECK-LABEL: fn main +// CHECK-LABEL: fn main( fn main() { - // CHECK: debug s => [[s:_[0-9]+]]; - // CHECK: debug a => [[a:_[0-9]+]]; - // CHECK: debug b => [[b:_[0-9]+]]; - // CHECK: debug a1 => [[a1:_[0-9]+]]; - // CHECK: debug b1 => [[b1:_[0-9]+]]; - // CHECK: debug c1 => [[c1:_[0-9]+]]; - // CHECK: debug a2 => [[a2:_[0-9]+]]; - // CHECK: debug b2 => [[b2:_[0-9]+]]; - // CHECK: debug c2 => [[c2:_[0-9]+]]; - // CHECK: debug ss => [[ss:_[0-9]+]]; - // CHECK: debug a3 => [[a3:_[0-9]+]]; - // CHECK: debug b3 => [[b3:_[0-9]+]]; - // CHECK: debug c3 => [[c3:_[0-9]+]]; - // CHECK: debug a4 => [[a4:_[0-9]+]]; - // CHECK: debug b4 => [[b4:_[0-9]+]]; - // CHECK: debug c4 => [[c4:_[0-9]+]]; - // CHECK: debug bs => [[bs:_[0-9]+]]; + // CHECK: debug s => [[s:_.*]]; + // CHECK: debug a => [[a:_.*]]; + // CHECK: debug b => [[b:_.*]]; + // CHECK: debug a1 => [[a1:_.*]]; + // CHECK: debug b1 => [[b1:_.*]]; + // CHECK: debug c1 => [[c1:_.*]]; + // CHECK: debug a2 => [[a2:_.*]]; + // CHECK: debug b2 => [[b2:_.*]]; + // CHECK: debug c2 => [[c2:_.*]]; + // CHECK: debug ss => [[ss:_.*]]; + // CHECK: debug a3 => [[a3:_.*]]; + // CHECK: debug b3 => [[b3:_.*]]; + // CHECK: debug c3 => [[c3:_.*]]; + // CHECK: debug a4 => [[a4:_.*]]; + // CHECK: debug b4 => [[b4:_.*]]; + // CHECK: debug c4 => [[c4:_.*]]; + // CHECK: debug bs => [[bs:_.*]]; // CHECK: [[s]] = const S(1_i32); let mut s = S(1); @@ -46,34 +46,34 @@ fn main() { // CHECK: [[a1]] = const 4f32; // CHECK: [[b1]] = const Option::::Some(S(1_i32)); - // CHECK: [[c1]] = ({{_[0-9]+}}.2: &[f32]); + // CHECK: [[c1]] = ({{_.*}}.2: &[f32]); let SmallStruct(a1, b1, c1) = SMALL_VAL; static SMALL_STAT: &SmallStruct = &SmallStruct(9., None, &[13.]); // CHECK: [[a2]] = const 9f32; - // CHECK: [[b2]] = ((*{{_[0-9]+}}).1: std::option::Option); - // CHECK: [[c2]] = ((*{{_[0-9]+}}).2: &[f32]); + // CHECK: [[b2]] = ((*{{_.*}}).1: std::option::Option); + // CHECK: [[c2]] = ((*{{_.*}}).2: &[f32]); let SmallStruct(a2, b2, c2) = *SMALL_STAT; - // CHECK: [[ss]] = SmallStruct(const 9f32, move {{_[0-9]+}}, move {{_[0-9]+}}); + // CHECK: [[ss]] = SmallStruct(const 9f32, move {{_.*}}, move {{_.*}}); let ss = SmallStruct(a2, b2, c2); const BIG_VAL: BigStruct = BigStruct(25., None, &[]); // CHECK: [[a3]] = const 25f32; - // CHECK: [[b3]] = ({{_[0-9]+}}.1: std::option::Option); - // CHECK: [[c3]] = ({{_[0-9]+}}.2: &[f32]); + // CHECK: [[b3]] = ({{_.*}}.1: std::option::Option); + // CHECK: [[c3]] = ({{_.*}}.2: &[f32]); let BigStruct(a3, b3, c3) = BIG_VAL; static BIG_STAT: &BigStruct = &BigStruct(82., Some(S(35)), &[45., 72.]); // CHECK: [[a4]] = const 82f32; // CHECK: [[b4]] = const Option::::Some(S(35_i32)); - // CHECK: [[c4]] = ((*{{_[0-9]+}}).2: &[f32]); + // CHECK: [[c4]] = ((*{{_.*}}).2: &[f32]); let BigStruct(a4, b4, c4) = *BIG_STAT; // We arbitrarily limit the size of synthetized values to 4 pointers. // `BigStruct` can be read, but we will keep a MIR aggregate for this. - // CHECK: [[bs]] = BigStruct(const 82f32, const Option::::Some(S(35_i32)), move {{_[0-9]+}}); + // CHECK: [[bs]] = BigStruct(const 82f32, const Option::::Some(S(35_i32)), move {{_.*}}); let bs = BigStruct(a4, b4, c4); } diff --git a/tests/mir-opt/dataflow-const-prop/terminator.rs b/tests/mir-opt/dataflow-const-prop/terminator.rs index 985eddad264..37bf3b33470 100644 --- a/tests/mir-opt/dataflow-const-prop/terminator.rs +++ b/tests/mir-opt/dataflow-const-prop/terminator.rs @@ -5,10 +5,10 @@ fn foo(n: i32) {} // EMIT_MIR terminator.main.DataflowConstProp.diff -// CHECK-LABEL: fn main +// CHECK-LABEL: fn main( fn main() { let a = 1; // Checks that we propagate into terminators. - // CHECK: {{_[0-9]+}} = foo(const 2_i32) -> [return: {{bb[0-9]+}}, unwind continue]; + // CHECK: {{_.*}} = foo(const 2_i32) -> [return: {{bb.*}}, unwind continue]; foo(a + 1); } diff --git a/tests/mir-opt/dataflow-const-prop/tuple.rs b/tests/mir-opt/dataflow-const-prop/tuple.rs index bd5adeda8b3..563558da04a 100644 --- a/tests/mir-opt/dataflow-const-prop/tuple.rs +++ b/tests/mir-opt/dataflow-const-prop/tuple.rs @@ -3,12 +3,12 @@ // EMIT_MIR tuple.main.DataflowConstProp.diff -// CHECK-LABEL: fn main +// CHECK-LABEL: fn main( fn main() { - // CHECK: debug a => [[a:_[0-9]+]]; - // CHECK: debug b => [[b:_[0-9]+]]; - // CHECK: debug c => [[c:_[0-9]+]]; - // CHECK: debug d => [[d:_[0-9]+]]; + // CHECK: debug a => [[a:_.*]]; + // CHECK: debug b => [[b:_.*]]; + // CHECK: debug c => [[c:_.*]]; + // CHECK: debug d => [[d:_.*]]; // CHECK: [[a]] = const (1_i32, 2_i32); let mut a = (1, 2);