diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index 274eea9563fe8..2fb10b1e9558d 100644 --- a/compiler/rustc_mir_transform/src/gvn.rs +++ b/compiler/rustc_mir_transform/src/gvn.rs @@ -636,7 +636,9 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { let proj = match proj { ProjectionElem::Deref => { let ty = place.ty(self.local_decls, self.tcx).ty; - if let Some(Mutability::Not) = ty.ref_mutability() + // unsound: https://github.com/rust-lang/rust/issues/130853 + if self.tcx.sess.opts.unstable_opts.unsound_mir_opts + && let Some(Mutability::Not) = ty.ref_mutability() && let Some(pointee_ty) = ty.builtin_deref(true) && pointee_ty.is_freeze(self.tcx, self.param_env) { diff --git a/tests/coverage/closure.cov-map b/tests/coverage/closure.cov-map index d50f9f8e7afaa..b608c0dd40f27 100644 --- a/tests/coverage/closure.cov-map +++ b/tests/coverage/closure.cov-map @@ -142,17 +142,19 @@ Number of file 0 mappings: 6 - Code(Counter(0)) at (prev + 2, 9) to (start + 0, 10) Highest counter ID seen: c1 -Function name: closure::main::{closure#18} (unused) -Raw bytes (24): 0x[01, 01, 00, 04, 00, 19, 0d, 02, 1c, 00, 02, 1d, 02, 12, 00, 02, 12, 00, 13, 00, 01, 11, 01, 0e] +Function name: closure::main::{closure#18} +Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 19, 0d, 02, 1c, 05, 02, 1d, 02, 12, 02, 02, 12, 00, 13, 01, 01, 11, 01, 0e] Number of files: 1 - file 0 => global file 1 -Number of expressions: 0 +Number of expressions: 1 +- expression 0 operands: lhs = Counter(0), rhs = Counter(1) Number of file 0 mappings: 4 -- Code(Zero) at (prev + 25, 13) to (start + 2, 28) -- Code(Zero) at (prev + 2, 29) to (start + 2, 18) -- Code(Zero) at (prev + 2, 18) to (start + 0, 19) -- Code(Zero) at (prev + 1, 17) to (start + 1, 14) -Highest counter ID seen: (none) +- Code(Counter(0)) at (prev + 25, 13) to (start + 2, 28) +- Code(Counter(1)) at (prev + 2, 29) to (start + 2, 18) +- Code(Expression(0, Sub)) at (prev + 2, 18) to (start + 0, 19) + = (c0 - c1) +- Code(Counter(0)) at (prev + 1, 17) to (start + 1, 14) +Highest counter ID seen: c1 Function name: closure::main::{closure#19} Raw bytes (26): 0x[01, 01, 01, 01, 05, 04, 01, 43, 0d, 02, 1c, 05, 02, 1d, 02, 12, 02, 02, 12, 00, 13, 01, 01, 11, 01, 0e] diff --git a/tests/coverage/issue-84561.cov-map b/tests/coverage/issue-84561.cov-map index a8ad17574ba3d..64870c434b33d 100644 --- a/tests/coverage/issue-84561.cov-map +++ b/tests/coverage/issue-84561.cov-map @@ -59,59 +59,69 @@ Number of file 0 mappings: 1 Highest counter ID seen: c0 Function name: issue_84561::test3 -Raw bytes (375): 0x[01, 01, 31, 05, 09, 0d, 00, 15, 19, 12, 00, 15, 19, 21, 00, 1e, 00, 21, 00, 31, 00, 3d, 00, 2e, 45, 3d, 00, 42, 49, 45, 00, 3f, 51, 42, 49, 45, 00, 7a, 55, 51, 00, 7a, 55, 51, 00, 77, 5d, 7a, 55, 51, 00, 77, 61, 7a, 55, 51, 00, 72, 65, 77, 61, 7a, 55, 51, 00, 75, be, 01, c2, 01, 79, 69, 6d, 69, 6d, 69, 6d, c2, 01, 00, 69, 6d, c2, 01, 79, 69, 6d, bb, 01, 7d, 75, be, 01, c2, 01, 79, 69, 6d, b6, 01, 00, bb, 01, 7d, 75, be, 01, c2, 01, 79, 69, 6d, 33, 01, 08, 01, 03, 1c, 05, 04, 09, 01, 1c, 02, 02, 05, 04, 1f, 0d, 05, 05, 00, 1f, 06, 01, 05, 00, 1f, 15, 01, 09, 01, 1c, 12, 02, 05, 00, 1f, 0e, 01, 05, 00, 0f, 00, 00, 20, 00, 30, 21, 01, 05, 03, 0f, 00, 03, 20, 00, 30, 00, 00, 33, 00, 41, 00, 00, 4b, 00, 5a, 1e, 01, 05, 00, 0f, 00, 05, 09, 03, 10, 00, 05, 0d, 00, 1b, 00, 02, 0d, 00, 1c, 1a, 04, 09, 05, 06, 31, 06, 05, 03, 06, 22, 04, 05, 03, 06, 3d, 04, 09, 04, 06, 2e, 05, 08, 00, 0f, 45, 01, 09, 03, 0a, 2a, 05, 09, 03, 0a, 3f, 05, 08, 00, 0f, 51, 01, 09, 00, 13, 00, 03, 0d, 00, 1d, 3a, 03, 09, 00, 13, 00, 03, 0d, 00, 1d, 77, 03, 05, 00, 0f, 77, 01, 0c, 00, 13, 5d, 01, 0d, 00, 13, 56, 02, 0d, 00, 13, 72, 04, 05, 02, 13, 65, 03, 0d, 00, 13, 6e, 02, 0d, 00, 13, bb, 01, 03, 05, 00, 0f, 69, 01, 0c, 00, 13, 6d, 01, 0d, 03, 0e, 75, 04, 0d, 00, 13, c2, 01, 02, 0d, 00, 17, c2, 01, 01, 14, 00, 1b, 00, 01, 15, 00, 1b, 92, 01, 02, 15, 00, 1b, be, 01, 04, 0d, 00, 13, 7d, 03, 09, 00, 19, b6, 01, 02, 05, 00, 0f, b2, 01, 03, 09, 00, 22, 00, 02, 05, 00, 0f, 00, 03, 09, 00, 2c, 00, 02, 01, 00, 02] +Raw bytes (414): 0x[01, 01, 3b, 05, 09, 0d, 11, 15, 19, 1e, 1d, 15, 19, 1a, 21, 1e, 1d, 15, 19, 25, 2d, 21, 25, 29, 35, 32, 29, 21, 25, 31, 39, 3d, 41, 42, 45, 3d, 41, 66, 49, 45, 4d, 63, 51, 66, 49, 45, 4d, 5e, 55, 63, 51, 66, 49, 45, 4d, 9e, 01, 55, 51, 59, 9e, 01, 55, 51, 59, 9b, 01, 5d, 9e, 01, 55, 51, 59, 9b, 01, 61, 9e, 01, 55, 51, 59, 96, 01, 65, 9b, 01, 61, 9e, 01, 55, 51, 59, 75, e2, 01, e6, 01, 79, 69, 6d, 69, 6d, 69, 6d, e6, 01, 00, 69, 6d, e6, 01, 79, 69, 6d, df, 01, 7d, 75, e2, 01, e6, 01, 79, 69, 6d, da, 01, 81, 01, df, 01, 7d, 75, e2, 01, e6, 01, 79, 69, 6d, 81, 01, 85, 01, 33, 01, 08, 01, 03, 1c, 05, 04, 09, 01, 1c, 02, 02, 05, 04, 1f, 0d, 05, 05, 00, 1f, 06, 01, 05, 00, 1f, 15, 01, 09, 01, 1c, 1e, 02, 05, 00, 1f, 1a, 01, 05, 00, 0f, 16, 00, 20, 00, 30, 21, 01, 05, 03, 0f, 25, 03, 20, 00, 30, 2d, 00, 33, 00, 41, 22, 00, 4b, 00, 5a, 32, 01, 05, 00, 0f, 29, 05, 09, 03, 10, 35, 05, 0d, 00, 1b, 2a, 02, 0d, 00, 1c, 2e, 04, 09, 05, 06, 31, 06, 05, 03, 06, 36, 04, 05, 03, 06, 3d, 04, 09, 04, 06, 42, 05, 08, 00, 0f, 45, 01, 09, 03, 0a, 3e, 05, 09, 03, 0a, 63, 05, 08, 00, 0f, 51, 01, 09, 00, 13, 59, 03, 0d, 00, 1d, 5e, 03, 09, 00, 13, 5a, 03, 0d, 00, 1d, 9b, 01, 03, 05, 00, 0f, 9b, 01, 01, 0c, 00, 13, 5d, 01, 0d, 00, 13, 7a, 02, 0d, 00, 13, 96, 01, 04, 05, 02, 13, 65, 03, 0d, 00, 13, 92, 01, 02, 0d, 00, 13, df, 01, 03, 05, 00, 0f, 69, 01, 0c, 00, 13, 6d, 01, 0d, 03, 0e, 75, 04, 0d, 00, 13, e6, 01, 02, 0d, 00, 17, e6, 01, 01, 14, 00, 1b, 00, 01, 15, 00, 1b, b6, 01, 02, 15, 00, 1b, e2, 01, 04, 0d, 00, 13, 7d, 03, 09, 00, 19, da, 01, 02, 05, 00, 0f, d6, 01, 03, 09, 00, 22, 81, 01, 02, 05, 00, 0f, ea, 01, 03, 09, 00, 2c, 85, 01, 02, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 49 +Number of expressions: 59 - expression 0 operands: lhs = Counter(1), rhs = Counter(2) -- expression 1 operands: lhs = Counter(3), rhs = Zero +- expression 1 operands: lhs = Counter(3), rhs = Counter(4) - expression 2 operands: lhs = Counter(5), rhs = Counter(6) -- expression 3 operands: lhs = Expression(4, Sub), rhs = Zero +- expression 3 operands: lhs = Expression(7, Sub), rhs = Counter(7) - expression 4 operands: lhs = Counter(5), rhs = Counter(6) -- expression 5 operands: lhs = Counter(8), rhs = Zero -- expression 6 operands: lhs = Expression(7, Sub), rhs = Zero -- expression 7 operands: lhs = Counter(8), rhs = Zero -- expression 8 operands: lhs = Counter(12), rhs = Zero -- expression 9 operands: lhs = Counter(15), rhs = Zero -- expression 10 operands: lhs = Expression(11, Sub), rhs = Counter(17) -- expression 11 operands: lhs = Counter(15), rhs = Zero -- expression 12 operands: lhs = Expression(16, Sub), rhs = Counter(18) -- expression 13 operands: lhs = Counter(17), rhs = Zero -- expression 14 operands: lhs = Expression(15, Add), rhs = Counter(20) -- expression 15 operands: lhs = Expression(16, Sub), rhs = Counter(18) -- expression 16 operands: lhs = Counter(17), rhs = Zero -- expression 17 operands: lhs = Expression(30, Sub), rhs = Counter(21) -- expression 18 operands: lhs = Counter(20), rhs = Zero -- expression 19 operands: lhs = Expression(30, Sub), rhs = Counter(21) -- expression 20 operands: lhs = Counter(20), rhs = Zero -- expression 21 operands: lhs = Expression(29, Add), rhs = Counter(23) -- expression 22 operands: lhs = Expression(30, Sub), rhs = Counter(21) -- expression 23 operands: lhs = Counter(20), rhs = Zero -- expression 24 operands: lhs = Expression(29, Add), rhs = Counter(24) -- expression 25 operands: lhs = Expression(30, Sub), rhs = Counter(21) -- expression 26 operands: lhs = Counter(20), rhs = Zero -- expression 27 operands: lhs = Expression(28, Sub), rhs = Counter(25) -- expression 28 operands: lhs = Expression(29, Add), rhs = Counter(24) -- expression 29 operands: lhs = Expression(30, Sub), rhs = Counter(21) -- expression 30 operands: lhs = Counter(20), rhs = Zero -- expression 31 operands: lhs = Counter(29), rhs = Expression(47, Sub) -- expression 32 operands: lhs = Expression(48, Sub), rhs = Counter(30) -- expression 33 operands: lhs = Counter(26), rhs = Counter(27) -- expression 34 operands: lhs = Counter(26), rhs = Counter(27) -- expression 35 operands: lhs = Counter(26), rhs = Counter(27) -- expression 36 operands: lhs = Expression(48, Sub), rhs = Zero -- expression 37 operands: lhs = Counter(26), rhs = Counter(27) -- expression 38 operands: lhs = Expression(48, Sub), rhs = Counter(30) -- expression 39 operands: lhs = Counter(26), rhs = Counter(27) -- expression 40 operands: lhs = Expression(46, Add), rhs = Counter(31) -- expression 41 operands: lhs = Counter(29), rhs = Expression(47, Sub) -- expression 42 operands: lhs = Expression(48, Sub), rhs = Counter(30) +- expression 5 operands: lhs = Expression(6, Sub), rhs = Counter(8) +- expression 6 operands: lhs = Expression(7, Sub), rhs = Counter(7) +- expression 7 operands: lhs = Counter(5), rhs = Counter(6) +- expression 8 operands: lhs = Counter(9), rhs = Counter(11) +- expression 9 operands: lhs = Counter(8), rhs = Counter(9) +- expression 10 operands: lhs = Counter(10), rhs = Counter(13) +- expression 11 operands: lhs = Expression(12, Sub), rhs = Counter(10) +- expression 12 operands: lhs = Counter(8), rhs = Counter(9) +- expression 13 operands: lhs = Counter(12), rhs = Counter(14) +- expression 14 operands: lhs = Counter(15), rhs = Counter(16) +- expression 15 operands: lhs = Expression(16, Sub), rhs = Counter(17) +- expression 16 operands: lhs = Counter(15), rhs = Counter(16) +- expression 17 operands: lhs = Expression(25, Sub), rhs = Counter(18) +- expression 18 operands: lhs = Counter(17), rhs = Counter(19) +- expression 19 operands: lhs = Expression(24, Add), rhs = Counter(20) +- expression 20 operands: lhs = Expression(25, Sub), rhs = Counter(18) +- expression 21 operands: lhs = Counter(17), rhs = Counter(19) +- expression 22 operands: lhs = Expression(23, Sub), rhs = Counter(21) +- expression 23 operands: lhs = Expression(24, Add), rhs = Counter(20) +- expression 24 operands: lhs = Expression(25, Sub), rhs = Counter(18) +- expression 25 operands: lhs = Counter(17), rhs = Counter(19) +- expression 26 operands: lhs = Expression(39, Sub), rhs = Counter(21) +- expression 27 operands: lhs = Counter(20), rhs = Counter(22) +- expression 28 operands: lhs = Expression(39, Sub), rhs = Counter(21) +- expression 29 operands: lhs = Counter(20), rhs = Counter(22) +- expression 30 operands: lhs = Expression(38, Add), rhs = Counter(23) +- expression 31 operands: lhs = Expression(39, Sub), rhs = Counter(21) +- expression 32 operands: lhs = Counter(20), rhs = Counter(22) +- expression 33 operands: lhs = Expression(38, Add), rhs = Counter(24) +- expression 34 operands: lhs = Expression(39, Sub), rhs = Counter(21) +- expression 35 operands: lhs = Counter(20), rhs = Counter(22) +- expression 36 operands: lhs = Expression(37, Sub), rhs = Counter(25) +- expression 37 operands: lhs = Expression(38, Add), rhs = Counter(24) +- expression 38 operands: lhs = Expression(39, Sub), rhs = Counter(21) +- expression 39 operands: lhs = Counter(20), rhs = Counter(22) +- expression 40 operands: lhs = Counter(29), rhs = Expression(56, Sub) +- expression 41 operands: lhs = Expression(57, Sub), rhs = Counter(30) +- expression 42 operands: lhs = Counter(26), rhs = Counter(27) - expression 43 operands: lhs = Counter(26), rhs = Counter(27) -- expression 44 operands: lhs = Expression(45, Sub), rhs = Zero -- expression 45 operands: lhs = Expression(46, Add), rhs = Counter(31) -- expression 46 operands: lhs = Counter(29), rhs = Expression(47, Sub) -- expression 47 operands: lhs = Expression(48, Sub), rhs = Counter(30) +- expression 44 operands: lhs = Counter(26), rhs = Counter(27) +- expression 45 operands: lhs = Expression(57, Sub), rhs = Zero +- expression 46 operands: lhs = Counter(26), rhs = Counter(27) +- expression 47 operands: lhs = Expression(57, Sub), rhs = Counter(30) - expression 48 operands: lhs = Counter(26), rhs = Counter(27) +- expression 49 operands: lhs = Expression(55, Add), rhs = Counter(31) +- expression 50 operands: lhs = Counter(29), rhs = Expression(56, Sub) +- expression 51 operands: lhs = Expression(57, Sub), rhs = Counter(30) +- expression 52 operands: lhs = Counter(26), rhs = Counter(27) +- expression 53 operands: lhs = Expression(54, Sub), rhs = Counter(32) +- expression 54 operands: lhs = Expression(55, Add), rhs = Counter(31) +- expression 55 operands: lhs = Counter(29), rhs = Expression(56, Sub) +- expression 56 operands: lhs = Expression(57, Sub), rhs = Counter(30) +- expression 57 operands: lhs = Counter(26), rhs = Counter(27) +- expression 58 operands: lhs = Counter(32), rhs = Counter(33) Number of file 0 mappings: 51 - Code(Counter(0)) at (prev + 8, 1) to (start + 3, 28) - Code(Counter(1)) at (prev + 4, 9) to (start + 1, 28) @@ -119,73 +129,78 @@ Number of file 0 mappings: 51 = (c1 - c2) - Code(Counter(3)) at (prev + 5, 5) to (start + 0, 31) - Code(Expression(1, Sub)) at (prev + 1, 5) to (start + 0, 31) - = (c3 - Zero) + = (c3 - c4) - Code(Counter(5)) at (prev + 1, 9) to (start + 1, 28) -- Code(Expression(4, Sub)) at (prev + 2, 5) to (start + 0, 31) +- Code(Expression(7, Sub)) at (prev + 2, 5) to (start + 0, 31) = (c5 - c6) -- Code(Expression(3, Sub)) at (prev + 1, 5) to (start + 0, 15) - = ((c5 - c6) - Zero) -- Code(Zero) at (prev + 0, 32) to (start + 0, 48) +- Code(Expression(6, Sub)) at (prev + 1, 5) to (start + 0, 15) + = ((c5 - c6) - c7) +- Code(Expression(5, Sub)) at (prev + 0, 32) to (start + 0, 48) + = (((c5 - c6) - c7) - c8) - Code(Counter(8)) at (prev + 1, 5) to (start + 3, 15) -- Code(Zero) at (prev + 3, 32) to (start + 0, 48) -- Code(Zero) at (prev + 0, 51) to (start + 0, 65) -- Code(Zero) at (prev + 0, 75) to (start + 0, 90) -- Code(Expression(7, Sub)) at (prev + 1, 5) to (start + 0, 15) - = (c8 - Zero) -- Code(Zero) at (prev + 5, 9) to (start + 3, 16) -- Code(Zero) at (prev + 5, 13) to (start + 0, 27) -- Code(Zero) at (prev + 2, 13) to (start + 0, 28) -- Code(Expression(6, Sub)) at (prev + 4, 9) to (start + 5, 6) - = ((c8 - Zero) - Zero) +- Code(Counter(9)) at (prev + 3, 32) to (start + 0, 48) +- Code(Counter(11)) at (prev + 0, 51) to (start + 0, 65) +- Code(Expression(8, Sub)) at (prev + 0, 75) to (start + 0, 90) + = (c9 - c11) +- Code(Expression(12, Sub)) at (prev + 1, 5) to (start + 0, 15) + = (c8 - c9) +- Code(Counter(10)) at (prev + 5, 9) to (start + 3, 16) +- Code(Counter(13)) at (prev + 5, 13) to (start + 0, 27) +- Code(Expression(10, Sub)) at (prev + 2, 13) to (start + 0, 28) + = (c10 - c13) +- Code(Expression(11, Sub)) at (prev + 4, 9) to (start + 5, 6) + = ((c8 - c9) - c10) - Code(Counter(12)) at (prev + 6, 5) to (start + 3, 6) -- Code(Expression(8, Sub)) at (prev + 4, 5) to (start + 3, 6) - = (c12 - Zero) +- Code(Expression(13, Sub)) at (prev + 4, 5) to (start + 3, 6) + = (c12 - c14) - Code(Counter(15)) at (prev + 4, 9) to (start + 4, 6) -- Code(Expression(11, Sub)) at (prev + 5, 8) to (start + 0, 15) - = (c15 - Zero) +- Code(Expression(16, Sub)) at (prev + 5, 8) to (start + 0, 15) + = (c15 - c16) - Code(Counter(17)) at (prev + 1, 9) to (start + 3, 10) -- Code(Expression(10, Sub)) at (prev + 5, 9) to (start + 3, 10) - = ((c15 - Zero) - c17) -- Code(Expression(15, Add)) at (prev + 5, 8) to (start + 0, 15) - = ((c17 - Zero) + c18) +- Code(Expression(15, Sub)) at (prev + 5, 9) to (start + 3, 10) + = ((c15 - c16) - c17) +- Code(Expression(24, Add)) at (prev + 5, 8) to (start + 0, 15) + = ((c17 - c19) + c18) - Code(Counter(20)) at (prev + 1, 9) to (start + 0, 19) -- Code(Zero) at (prev + 3, 13) to (start + 0, 29) -- Code(Expression(14, Sub)) at (prev + 3, 9) to (start + 0, 19) - = (((c17 - Zero) + c18) - c20) -- Code(Zero) at (prev + 3, 13) to (start + 0, 29) -- Code(Expression(29, Add)) at (prev + 3, 5) to (start + 0, 15) - = ((c20 - Zero) + c21) -- Code(Expression(29, Add)) at (prev + 1, 12) to (start + 0, 19) - = ((c20 - Zero) + c21) +- Code(Counter(22)) at (prev + 3, 13) to (start + 0, 29) +- Code(Expression(23, Sub)) at (prev + 3, 9) to (start + 0, 19) + = (((c17 - c19) + c18) - c20) +- Code(Expression(22, Sub)) at (prev + 3, 13) to (start + 0, 29) + = ((((c17 - c19) + c18) - c20) - c21) +- Code(Expression(38, Add)) at (prev + 3, 5) to (start + 0, 15) + = ((c20 - c22) + c21) +- Code(Expression(38, Add)) at (prev + 1, 12) to (start + 0, 19) + = ((c20 - c22) + c21) - Code(Counter(23)) at (prev + 1, 13) to (start + 0, 19) -- Code(Expression(21, Sub)) at (prev + 2, 13) to (start + 0, 19) - = (((c20 - Zero) + c21) - c23) -- Code(Expression(28, Sub)) at (prev + 4, 5) to (start + 2, 19) - = (((c20 - Zero) + c21) - c24) +- Code(Expression(30, Sub)) at (prev + 2, 13) to (start + 0, 19) + = (((c20 - c22) + c21) - c23) +- Code(Expression(37, Sub)) at (prev + 4, 5) to (start + 2, 19) + = (((c20 - c22) + c21) - c24) - Code(Counter(25)) at (prev + 3, 13) to (start + 0, 19) -- Code(Expression(27, Sub)) at (prev + 2, 13) to (start + 0, 19) - = ((((c20 - Zero) + c21) - c24) - c25) -- Code(Expression(46, Add)) at (prev + 3, 5) to (start + 0, 15) +- Code(Expression(36, Sub)) at (prev + 2, 13) to (start + 0, 19) + = ((((c20 - c22) + c21) - c24) - c25) +- Code(Expression(55, Add)) at (prev + 3, 5) to (start + 0, 15) = (c29 + ((c26 - c27) - c30)) - Code(Counter(26)) at (prev + 1, 12) to (start + 0, 19) - Code(Counter(27)) at (prev + 1, 13) to (start + 3, 14) - Code(Counter(29)) at (prev + 4, 13) to (start + 0, 19) -- Code(Expression(48, Sub)) at (prev + 2, 13) to (start + 0, 23) +- Code(Expression(57, Sub)) at (prev + 2, 13) to (start + 0, 23) = (c26 - c27) -- Code(Expression(48, Sub)) at (prev + 1, 20) to (start + 0, 27) +- Code(Expression(57, Sub)) at (prev + 1, 20) to (start + 0, 27) = (c26 - c27) - Code(Zero) at (prev + 1, 21) to (start + 0, 27) -- Code(Expression(36, Sub)) at (prev + 2, 21) to (start + 0, 27) +- Code(Expression(45, Sub)) at (prev + 2, 21) to (start + 0, 27) = ((c26 - c27) - Zero) -- Code(Expression(47, Sub)) at (prev + 4, 13) to (start + 0, 19) +- Code(Expression(56, Sub)) at (prev + 4, 13) to (start + 0, 19) = ((c26 - c27) - c30) - Code(Counter(31)) at (prev + 3, 9) to (start + 0, 25) -- Code(Expression(45, Sub)) at (prev + 2, 5) to (start + 0, 15) +- Code(Expression(54, Sub)) at (prev + 2, 5) to (start + 0, 15) = ((c29 + ((c26 - c27) - c30)) - c31) -- Code(Expression(44, Sub)) at (prev + 3, 9) to (start + 0, 34) - = (((c29 + ((c26 - c27) - c30)) - c31) - Zero) -- Code(Zero) at (prev + 2, 5) to (start + 0, 15) -- Code(Zero) at (prev + 3, 9) to (start + 0, 44) -- Code(Zero) at (prev + 2, 1) to (start + 0, 2) -Highest counter ID seen: c31 +- Code(Expression(53, Sub)) at (prev + 3, 9) to (start + 0, 34) + = (((c29 + ((c26 - c27) - c30)) - c31) - c32) +- Code(Counter(32)) at (prev + 2, 5) to (start + 0, 15) +- Code(Expression(58, Sub)) at (prev + 3, 9) to (start + 0, 44) + = (c32 - c33) +- Code(Counter(33)) at (prev + 2, 1) to (start + 0, 2) +Highest counter ID seen: c33 diff --git a/tests/mir-opt/const_prop/read_immutable_static.main.GVN.diff b/tests/mir-opt/const_prop/read_immutable_static.main.GVN.diff index 8df262b351f12..23928337bf77f 100644 --- a/tests/mir-opt/const_prop/read_immutable_static.main.GVN.diff +++ b/tests/mir-opt/const_prop/read_immutable_static.main.GVN.diff @@ -14,23 +14,19 @@ bb0: { StorageLive(_1); -- StorageLive(_2); + StorageLive(_2); - StorageLive(_3); -+ nop; + nop; _3 = const {ALLOC0: &u8}; -- _2 = copy (*_3); -+ _2 = const 2_u8; + _2 = copy (*_3); StorageLive(_4); StorageLive(_5); _5 = const {ALLOC0: &u8}; - _4 = copy (*_5); -- _1 = Add(move _2, move _4); -+ _4 = const 2_u8; -+ _1 = const 4_u8; ++ _4 = copy (*_3); + _1 = Add(move _2, move _4); StorageDead(_4); -- StorageDead(_2); -+ nop; + StorageDead(_2); StorageDead(_5); - StorageDead(_3); + nop; diff --git a/tests/mir-opt/const_prop/read_immutable_static.rs b/tests/mir-opt/const_prop/read_immutable_static.rs index 05fec2f3303b0..f88e4b3de939f 100644 --- a/tests/mir-opt/const_prop/read_immutable_static.rs +++ b/tests/mir-opt/const_prop/read_immutable_static.rs @@ -6,6 +6,6 @@ static FOO: u8 = 2; fn main() { // CHECK-LABEL: fn main( // CHECK: debug x => [[x:_.*]]; - // CHECK: [[x]] = const 4_u8; + // CHECK-NOT: [[x]] = const 4_u8; let x = FOO + FOO; } diff --git a/tests/mir-opt/const_prop/ref_deref.main.GVN.diff b/tests/mir-opt/const_prop/ref_deref.main.GVN.diff index b9e269266b0b1..4477b4b005baf 100644 --- a/tests/mir-opt/const_prop/ref_deref.main.GVN.diff +++ b/tests/mir-opt/const_prop/ref_deref.main.GVN.diff @@ -16,8 +16,7 @@ StorageLive(_2); _4 = const main::promoted[0]; _2 = &(*_4); -- _1 = copy (*_2); -+ _1 = const 4_i32; + _1 = copy (*_2); StorageDead(_2); _0 = const (); StorageDead(_1); diff --git a/tests/mir-opt/const_prop/ref_deref_project.main.GVN.diff b/tests/mir-opt/const_prop/ref_deref_project.main.GVN.diff index dcc13c9251c41..bbfd70bea1684 100644 --- a/tests/mir-opt/const_prop/ref_deref_project.main.GVN.diff +++ b/tests/mir-opt/const_prop/ref_deref_project.main.GVN.diff @@ -16,8 +16,7 @@ StorageLive(_2); _4 = const main::promoted[0]; _2 = &((*_4).1: i32); -- _1 = copy (*_2); -+ _1 = const 5_i32; + _1 = copy (*_2); StorageDead(_2); _0 = const (); StorageDead(_1); diff --git a/tests/mir-opt/const_prop/ref_deref_project.rs b/tests/mir-opt/const_prop/ref_deref_project.rs index 5a48a887f93d7..813b4ae47455c 100644 --- a/tests/mir-opt/const_prop/ref_deref_project.rs +++ b/tests/mir-opt/const_prop/ref_deref_project.rs @@ -5,6 +5,6 @@ fn main() { // CHECK-LABEL: fn main( // CHECK: debug a => [[a:_.*]]; - // CHECK: [[a]] = const 5_i32; + // CHECK-NOT: [[a]] = const 5_i32; let a = *(&(4, 5).1); } diff --git a/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-abort.diff index 41ce94eda7517..8a8ea5b7e200b 100644 --- a/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-abort.diff @@ -30,17 +30,16 @@ StorageDead(_3); StorageLive(_6); _6 = const 1_usize; -- _7 = Len((*_2)); + _7 = Len((*_2)); - _8 = Lt(copy _6, copy _7); - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, copy _6) -> [success: bb1, unwind unreachable]; -+ _7 = const 3_usize; -+ _8 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> [success: bb1, unwind unreachable]; ++ _8 = Lt(const 1_usize, copy _7); ++ assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, const 1_usize) -> [success: bb1, unwind unreachable]; } bb1: { - _1 = copy (*_2)[_6]; -+ _1 = const 2_u32; ++ _1 = copy (*_2)[1 of 2]; StorageDead(_6); StorageDead(_4); StorageDead(_2); diff --git a/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-unwind.diff index 8cced96cd4331..f0c844884f670 100644 --- a/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-unwind.diff @@ -30,17 +30,16 @@ StorageDead(_3); StorageLive(_6); _6 = const 1_usize; -- _7 = Len((*_2)); + _7 = Len((*_2)); - _8 = Lt(copy _6, copy _7); - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, copy _6) -> [success: bb1, unwind continue]; -+ _7 = const 3_usize; -+ _8 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> [success: bb1, unwind continue]; ++ _8 = Lt(const 1_usize, copy _7); ++ assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, const 1_usize) -> [success: bb1, unwind continue]; } bb1: { - _1 = copy (*_2)[_6]; -+ _1 = const 2_u32; ++ _1 = copy (*_2)[1 of 2]; StorageDead(_6); StorageDead(_4); StorageDead(_2); diff --git a/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-abort.diff index 41ce94eda7517..8a8ea5b7e200b 100644 --- a/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-abort.diff @@ -30,17 +30,16 @@ StorageDead(_3); StorageLive(_6); _6 = const 1_usize; -- _7 = Len((*_2)); + _7 = Len((*_2)); - _8 = Lt(copy _6, copy _7); - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, copy _6) -> [success: bb1, unwind unreachable]; -+ _7 = const 3_usize; -+ _8 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> [success: bb1, unwind unreachable]; ++ _8 = Lt(const 1_usize, copy _7); ++ assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, const 1_usize) -> [success: bb1, unwind unreachable]; } bb1: { - _1 = copy (*_2)[_6]; -+ _1 = const 2_u32; ++ _1 = copy (*_2)[1 of 2]; StorageDead(_6); StorageDead(_4); StorageDead(_2); diff --git a/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff index 8cced96cd4331..f0c844884f670 100644 --- a/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff @@ -30,17 +30,16 @@ StorageDead(_3); StorageLive(_6); _6 = const 1_usize; -- _7 = Len((*_2)); + _7 = Len((*_2)); - _8 = Lt(copy _6, copy _7); - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, copy _6) -> [success: bb1, unwind continue]; -+ _7 = const 3_usize; -+ _8 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> [success: bb1, unwind continue]; ++ _8 = Lt(const 1_usize, copy _7); ++ assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, const 1_usize) -> [success: bb1, unwind continue]; } bb1: { - _1 = copy (*_2)[_6]; -+ _1 = const 2_u32; ++ _1 = copy (*_2)[1 of 2]; StorageDead(_6); StorageDead(_4); StorageDead(_2); diff --git a/tests/mir-opt/const_prop/slice_len.rs b/tests/mir-opt/const_prop/slice_len.rs index ebd3c9e792dca..eb86e28408a34 100644 --- a/tests/mir-opt/const_prop/slice_len.rs +++ b/tests/mir-opt/const_prop/slice_len.rs @@ -8,7 +8,7 @@ fn main() { // CHECK-LABEL: fn main( // CHECK: debug a => [[a:_.*]]; // CHECK: [[slice:_.*]] = copy {{.*}} as &[u32] (PointerCoercion(Unsize, AsCast)); - // CHECK: assert(const true, - // CHECK: [[a]] = const 2_u32; + // CHECK-NOT: assert(const true, + // CHECK-NOT: [[a]] = const 2_u32; let a = (&[1u32, 2, 3] as &[u32])[1]; } diff --git a/tests/mir-opt/gvn.borrowed.GVN.panic-abort.diff b/tests/mir-opt/gvn.borrowed.GVN.panic-abort.diff index b0702696e1871..acbea13642c1f 100644 --- a/tests/mir-opt/gvn.borrowed.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.borrowed.GVN.panic-abort.diff @@ -18,8 +18,7 @@ } bb2: { -- _0 = opaque::(copy (*_3)) -> [return: bb3, unwind unreachable]; -+ _0 = opaque::(copy _1) -> [return: bb3, unwind unreachable]; + _0 = opaque::(copy (*_3)) -> [return: bb3, unwind unreachable]; } bb3: { diff --git a/tests/mir-opt/gvn.borrowed.GVN.panic-unwind.diff b/tests/mir-opt/gvn.borrowed.GVN.panic-unwind.diff index fe05d4deeede9..ba080bfdb07a9 100644 --- a/tests/mir-opt/gvn.borrowed.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.borrowed.GVN.panic-unwind.diff @@ -18,8 +18,7 @@ } bb2: { -- _0 = opaque::(copy (*_3)) -> [return: bb3, unwind continue]; -+ _0 = opaque::(copy _1) -> [return: bb3, unwind continue]; + _0 = opaque::(copy (*_3)) -> [return: bb3, unwind continue]; } bb3: { diff --git a/tests/mir-opt/gvn.dereferences.GVN.panic-abort.diff b/tests/mir-opt/gvn.dereferences.GVN.panic-abort.diff index a763614dc644b..ecd7bdc433cd9 100644 --- a/tests/mir-opt/gvn.dereferences.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.dereferences.GVN.panic-abort.diff @@ -107,23 +107,18 @@ StorageLive(_18); _18 = &(*_1); StorageLive(_19); -- StorageLive(_20); -+ nop; + StorageLive(_20); _20 = copy (*_18); -- _19 = opaque::(move _20) -> [return: bb7, unwind unreachable]; -+ _19 = opaque::(copy _20) -> [return: bb7, unwind unreachable]; + _19 = opaque::(move _20) -> [return: bb7, unwind unreachable]; } bb7: { -- StorageDead(_20); -+ nop; + StorageDead(_20); StorageDead(_19); StorageLive(_21); StorageLive(_22); -- _22 = copy (*_18); -- _21 = opaque::(move _22) -> [return: bb8, unwind unreachable]; -+ _22 = copy _20; -+ _21 = opaque::(copy _20) -> [return: bb8, unwind unreachable]; + _22 = copy (*_18); + _21 = opaque::(move _22) -> [return: bb8, unwind unreachable]; } bb8: { @@ -157,23 +152,18 @@ StorageDead(_28); StorageDead(_27); StorageLive(_29); -- StorageLive(_30); -+ nop; + StorageLive(_30); _30 = copy ((*_3).0: u32); -- _29 = opaque::(move _30) -> [return: bb12, unwind unreachable]; -+ _29 = opaque::(copy _30) -> [return: bb12, unwind unreachable]; + _29 = opaque::(move _30) -> [return: bb12, unwind unreachable]; } bb12: { -- StorageDead(_30); -+ nop; + StorageDead(_30); StorageDead(_29); StorageLive(_31); StorageLive(_32); -- _32 = copy ((*_3).0: u32); -- _31 = opaque::(move _32) -> [return: bb13, unwind unreachable]; -+ _32 = copy _30; -+ _31 = opaque::(copy _30) -> [return: bb13, unwind unreachable]; + _32 = copy ((*_3).0: u32); + _31 = opaque::(move _32) -> [return: bb13, unwind unreachable]; } bb13: { diff --git a/tests/mir-opt/gvn.dereferences.GVN.panic-unwind.diff b/tests/mir-opt/gvn.dereferences.GVN.panic-unwind.diff index ca6fda483642c..bbca6bc3c754d 100644 --- a/tests/mir-opt/gvn.dereferences.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.dereferences.GVN.panic-unwind.diff @@ -107,23 +107,18 @@ StorageLive(_18); _18 = &(*_1); StorageLive(_19); -- StorageLive(_20); -+ nop; + StorageLive(_20); _20 = copy (*_18); -- _19 = opaque::(move _20) -> [return: bb7, unwind continue]; -+ _19 = opaque::(copy _20) -> [return: bb7, unwind continue]; + _19 = opaque::(move _20) -> [return: bb7, unwind continue]; } bb7: { -- StorageDead(_20); -+ nop; + StorageDead(_20); StorageDead(_19); StorageLive(_21); StorageLive(_22); -- _22 = copy (*_18); -- _21 = opaque::(move _22) -> [return: bb8, unwind continue]; -+ _22 = copy _20; -+ _21 = opaque::(copy _20) -> [return: bb8, unwind continue]; + _22 = copy (*_18); + _21 = opaque::(move _22) -> [return: bb8, unwind continue]; } bb8: { @@ -157,23 +152,18 @@ StorageDead(_28); StorageDead(_27); StorageLive(_29); -- StorageLive(_30); -+ nop; + StorageLive(_30); _30 = copy ((*_3).0: u32); -- _29 = opaque::(move _30) -> [return: bb12, unwind continue]; -+ _29 = opaque::(copy _30) -> [return: bb12, unwind continue]; + _29 = opaque::(move _30) -> [return: bb12, unwind continue]; } bb12: { -- StorageDead(_30); -+ nop; + StorageDead(_30); StorageDead(_29); StorageLive(_31); StorageLive(_32); -- _32 = copy ((*_3).0: u32); -- _31 = opaque::(move _32) -> [return: bb13, unwind continue]; -+ _32 = copy _30; -+ _31 = opaque::(copy _30) -> [return: bb13, unwind continue]; + _32 = copy ((*_3).0: u32); + _31 = opaque::(move _32) -> [return: bb13, unwind continue]; } bb13: { diff --git a/tests/mir-opt/gvn.fn_pointers.GVN.panic-abort.diff b/tests/mir-opt/gvn.fn_pointers.GVN.panic-abort.diff index 130b011630cc2..3cce35d34e90d 100644 --- a/tests/mir-opt/gvn.fn_pointers.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.fn_pointers.GVN.panic-abort.diff @@ -8,10 +8,10 @@ let mut _3: fn(u8) -> u8; let _5: (); let mut _6: fn(u8) -> u8; - let mut _9: {closure@$DIR/gvn.rs:614:19: 614:21}; + let mut _9: {closure@$DIR/gvn.rs:620:19: 620:21}; let _10: (); let mut _11: fn(); - let mut _13: {closure@$DIR/gvn.rs:614:19: 614:21}; + let mut _13: {closure@$DIR/gvn.rs:620:19: 620:21}; let _14: (); let mut _15: fn(); scope 1 { @@ -19,7 +19,7 @@ let _4: fn(u8) -> u8; scope 2 { debug g => _4; - let _7: {closure@$DIR/gvn.rs:614:19: 614:21}; + let _7: {closure@$DIR/gvn.rs:620:19: 620:21}; scope 3 { debug closure => _7; let _8: fn(); @@ -62,16 +62,16 @@ StorageDead(_6); StorageDead(_5); - StorageLive(_7); -- _7 = {closure@$DIR/gvn.rs:614:19: 614:21}; +- _7 = {closure@$DIR/gvn.rs:620:19: 620:21}; - StorageLive(_8); + nop; -+ _7 = const ZeroSized: {closure@$DIR/gvn.rs:614:19: 614:21}; ++ _7 = const ZeroSized: {closure@$DIR/gvn.rs:620:19: 620:21}; + nop; StorageLive(_9); - _9 = copy _7; - _8 = move _9 as fn() (PointerCoercion(ClosureFnPointer(Safe), AsCast)); -+ _9 = const ZeroSized: {closure@$DIR/gvn.rs:614:19: 614:21}; -+ _8 = const ZeroSized: {closure@$DIR/gvn.rs:614:19: 614:21} as fn() (PointerCoercion(ClosureFnPointer(Safe), AsCast)); ++ _9 = const ZeroSized: {closure@$DIR/gvn.rs:620:19: 620:21}; ++ _8 = const ZeroSized: {closure@$DIR/gvn.rs:620:19: 620:21} as fn() (PointerCoercion(ClosureFnPointer(Safe), AsCast)); StorageDead(_9); StorageLive(_10); StorageLive(_11); @@ -88,8 +88,8 @@ StorageLive(_13); - _13 = copy _7; - _12 = move _13 as fn() (PointerCoercion(ClosureFnPointer(Safe), AsCast)); -+ _13 = const ZeroSized: {closure@$DIR/gvn.rs:614:19: 614:21}; -+ _12 = const ZeroSized: {closure@$DIR/gvn.rs:614:19: 614:21} as fn() (PointerCoercion(ClosureFnPointer(Safe), AsCast)); ++ _13 = const ZeroSized: {closure@$DIR/gvn.rs:620:19: 620:21}; ++ _12 = const ZeroSized: {closure@$DIR/gvn.rs:620:19: 620:21} as fn() (PointerCoercion(ClosureFnPointer(Safe), AsCast)); StorageDead(_13); StorageLive(_14); StorageLive(_15); diff --git a/tests/mir-opt/gvn.fn_pointers.GVN.panic-unwind.diff b/tests/mir-opt/gvn.fn_pointers.GVN.panic-unwind.diff index 372a08d547306..d85aca040fe67 100644 --- a/tests/mir-opt/gvn.fn_pointers.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.fn_pointers.GVN.panic-unwind.diff @@ -8,10 +8,10 @@ let mut _3: fn(u8) -> u8; let _5: (); let mut _6: fn(u8) -> u8; - let mut _9: {closure@$DIR/gvn.rs:614:19: 614:21}; + let mut _9: {closure@$DIR/gvn.rs:620:19: 620:21}; let _10: (); let mut _11: fn(); - let mut _13: {closure@$DIR/gvn.rs:614:19: 614:21}; + let mut _13: {closure@$DIR/gvn.rs:620:19: 620:21}; let _14: (); let mut _15: fn(); scope 1 { @@ -19,7 +19,7 @@ let _4: fn(u8) -> u8; scope 2 { debug g => _4; - let _7: {closure@$DIR/gvn.rs:614:19: 614:21}; + let _7: {closure@$DIR/gvn.rs:620:19: 620:21}; scope 3 { debug closure => _7; let _8: fn(); @@ -62,16 +62,16 @@ StorageDead(_6); StorageDead(_5); - StorageLive(_7); -- _7 = {closure@$DIR/gvn.rs:614:19: 614:21}; +- _7 = {closure@$DIR/gvn.rs:620:19: 620:21}; - StorageLive(_8); + nop; -+ _7 = const ZeroSized: {closure@$DIR/gvn.rs:614:19: 614:21}; ++ _7 = const ZeroSized: {closure@$DIR/gvn.rs:620:19: 620:21}; + nop; StorageLive(_9); - _9 = copy _7; - _8 = move _9 as fn() (PointerCoercion(ClosureFnPointer(Safe), AsCast)); -+ _9 = const ZeroSized: {closure@$DIR/gvn.rs:614:19: 614:21}; -+ _8 = const ZeroSized: {closure@$DIR/gvn.rs:614:19: 614:21} as fn() (PointerCoercion(ClosureFnPointer(Safe), AsCast)); ++ _9 = const ZeroSized: {closure@$DIR/gvn.rs:620:19: 620:21}; ++ _8 = const ZeroSized: {closure@$DIR/gvn.rs:620:19: 620:21} as fn() (PointerCoercion(ClosureFnPointer(Safe), AsCast)); StorageDead(_9); StorageLive(_10); StorageLive(_11); @@ -88,8 +88,8 @@ StorageLive(_13); - _13 = copy _7; - _12 = move _13 as fn() (PointerCoercion(ClosureFnPointer(Safe), AsCast)); -+ _13 = const ZeroSized: {closure@$DIR/gvn.rs:614:19: 614:21}; -+ _12 = const ZeroSized: {closure@$DIR/gvn.rs:614:19: 614:21} as fn() (PointerCoercion(ClosureFnPointer(Safe), AsCast)); ++ _13 = const ZeroSized: {closure@$DIR/gvn.rs:620:19: 620:21}; ++ _12 = const ZeroSized: {closure@$DIR/gvn.rs:620:19: 620:21} as fn() (PointerCoercion(ClosureFnPointer(Safe), AsCast)); StorageDead(_13); StorageLive(_14); StorageLive(_15); diff --git a/tests/mir-opt/gvn.rs b/tests/mir-opt/gvn.rs index faa6faa70179c..bb9435adebd91 100644 --- a/tests/mir-opt/gvn.rs +++ b/tests/mir-opt/gvn.rs @@ -99,12 +99,14 @@ fn subexpression_elimination(x: u64, y: u64, mut z: u64) { opaque((x * y) - y); opaque((x * y) - y); - // We can substitute through an immutable reference too. + // We cannot substitute through an immutable reference. // CHECK: [[ref:_.*]] = &_3; // CHECK: [[deref:_.*]] = copy (*[[ref]]); - // CHECK: [[addref:_.*]] = Add(copy [[deref]], copy _1); - // CHECK: opaque::(copy [[addref]]) - // CHECK: opaque::(copy [[addref]]) + // CHECK: [[addref:_.*]] = Add(move [[deref]], copy _1); + // CHECK: opaque::(move [[addref]]) + // CHECK: [[deref2:_.*]] = copy (*[[ref]]); + // CHECK: [[addref2:_.*]] = Add(move [[deref2]], copy _1); + // CHECK: opaque::(move [[addref2]]) let a = &z; opaque(*a + x); opaque(*a + x); @@ -137,13 +139,15 @@ fn subexpression_elimination(x: u64, y: u64, mut z: u64) { opaque(*d + x); } - // We can substitute again, but not with the earlier computations. + // We still cannot substitute again, and never with the earlier computations. // Important: `e` is not `a`! // CHECK: [[ref2:_.*]] = &_3; // CHECK: [[deref2:_.*]] = copy (*[[ref2]]); - // CHECK: [[addref2:_.*]] = Add(copy [[deref2]], copy _1); - // CHECK: opaque::(copy [[addref2]]) - // CHECK: opaque::(copy [[addref2]]) + // CHECK: [[addref2:_.*]] = Add(move [[deref2]], copy _1); + // CHECK: opaque::(move [[addref2]]) + // CHECK: [[deref3:_.*]] = copy (*[[ref2]]); + // CHECK: [[addref3:_.*]] = Add(move [[deref3]], copy _1); + // CHECK: opaque::(move [[addref3]]) let e = &z; opaque(*e + x); opaque(*e + x); @@ -495,15 +499,16 @@ fn dereferences(t: &mut u32, u: &impl Copy, s: &S) { unsafe { opaque(*z) }; unsafe { opaque(*z) }; - // We can reuse dereferences of `&Freeze`. + // Do not reuse dereferences of `&Freeze`. // CHECK: [[ref:_.*]] = &(*_1); // CHECK: [[st7:_.*]] = copy (*[[ref]]); - // CHECK: opaque::(copy [[st7]]) - // CHECK: opaque::(copy [[st7]]) + // CHECK: opaque::(move [[st7]]) + // CHECK: [[st8:_.*]] = copy (*[[ref]]); + // CHECK: opaque::(move [[st8]]) let z = &*t; opaque(*z); opaque(*z); - // But not in reborrows. + // Not in reborrows either. // CHECK: [[reborrow:_.*]] = &(*[[ref]]); // CHECK: opaque::<&u32>(move [[reborrow]]) opaque(&*z); @@ -516,10 +521,11 @@ fn dereferences(t: &mut u32, u: &impl Copy, s: &S) { opaque(*u); opaque(*u); - // `*s` is not Copy, but `(*s).0` is, so we can reuse. + // `*s` is not Copy, but `(*s).0` is, but we still cannot reuse. // CHECK: [[st10:_.*]] = copy ((*_3).0: u32); - // CHECK: opaque::(copy [[st10]]) - // CHECK: opaque::(copy [[st10]]) + // CHECK: opaque::(move [[st10]]) + // CHECK: [[st11:_.*]] = copy ((*_3).0: u32); + // CHECK: opaque::(move [[st11]]) opaque(s.0); opaque(s.0); } @@ -736,7 +742,7 @@ fn borrowed(x: T) { // CHECK: bb1: { // CHECK-NEXT: _0 = opaque::(copy _1) // CHECK: bb2: { - // CHECK-NEXT: _0 = opaque::(copy _1) + // CHECK-NEXT: _0 = opaque::(copy (*_3)) mir! { { let a = x; diff --git a/tests/mir-opt/gvn.slices.GVN.panic-abort.diff b/tests/mir-opt/gvn.slices.GVN.panic-abort.diff index e8e99b44e721b..43efcbdfb1e4b 100644 --- a/tests/mir-opt/gvn.slices.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.slices.GVN.panic-abort.diff @@ -111,9 +111,8 @@ StorageLive(_7); StorageLive(_8); - StorageLive(_9); -- StorageLive(_10); -+ nop; + nop; + StorageLive(_10); StorageLive(_11); _11 = &(*_1); _10 = core::str::::as_ptr(move _11) -> [return: bb3, unwind unreachable]; @@ -123,9 +122,8 @@ StorageDead(_11); _9 = &_10; - StorageLive(_12); -- StorageLive(_13); -+ nop; + nop; + StorageLive(_13); StorageLive(_14); - _14 = &(*_4); + _14 = &(*_1); @@ -150,12 +148,11 @@ StorageLive(_17); StorageLive(_18); - _18 = copy (*_15); -+ _18 = copy _10; ++ _18 = copy (*_9); StorageLive(_19); - _19 = copy (*_16); -- _17 = Eq(move _18, move _19); -+ _19 = copy _13; -+ _17 = Eq(copy _10, copy _13); ++ _19 = copy (*_12); + _17 = Eq(move _18, move _19); switchInt(move _17) -> [0: bb6, otherwise: bb5]; } @@ -166,10 +163,8 @@ StorageDead(_17); StorageDead(_16); StorageDead(_15); -- StorageDead(_13); -- StorageDead(_10); -+ nop; -+ nop; + StorageDead(_13); + StorageDead(_10); StorageDead(_8); StorageDead(_7); - StorageLive(_29); @@ -218,9 +213,8 @@ StorageLive(_33); StorageLive(_34); - StorageLive(_35); -- StorageLive(_36); -+ nop; + nop; + StorageLive(_36); StorageLive(_37); _37 = &(*_1); _36 = core::str::::as_ptr(move _37) -> [return: bb8, unwind unreachable]; @@ -230,9 +224,8 @@ StorageDead(_37); _35 = &_36; - StorageLive(_38); -- StorageLive(_39); -+ nop; + nop; + StorageLive(_39); StorageLive(_40); _40 = &(*_29); _39 = core::slice::::as_ptr(move _40) -> [return: bb9, unwind unreachable]; @@ -256,12 +249,11 @@ StorageLive(_43); StorageLive(_44); - _44 = copy (*_41); -+ _44 = copy _36; ++ _44 = copy (*_35); StorageLive(_45); - _45 = copy (*_42); -- _43 = Eq(move _44, move _45); -+ _45 = copy _39; -+ _43 = Eq(copy _36, copy _39); ++ _45 = copy (*_38); + _43 = Eq(move _44, move _45); switchInt(move _43) -> [0: bb11, otherwise: bb10]; } @@ -272,10 +264,8 @@ StorageDead(_43); StorageDead(_42); StorageDead(_41); -- StorageDead(_39); -- StorageDead(_36); -+ nop; -+ nop; + StorageDead(_39); + StorageDead(_36); StorageDead(_34); StorageDead(_33); _0 = const (); diff --git a/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff b/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff index 4296d4d4a5945..8572f538c0ff7 100644 --- a/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.slices.GVN.panic-unwind.diff @@ -111,9 +111,8 @@ StorageLive(_7); StorageLive(_8); - StorageLive(_9); -- StorageLive(_10); -+ nop; + nop; + StorageLive(_10); StorageLive(_11); _11 = &(*_1); _10 = core::str::::as_ptr(move _11) -> [return: bb3, unwind continue]; @@ -123,9 +122,8 @@ StorageDead(_11); _9 = &_10; - StorageLive(_12); -- StorageLive(_13); -+ nop; + nop; + StorageLive(_13); StorageLive(_14); - _14 = &(*_4); + _14 = &(*_1); @@ -150,12 +148,11 @@ StorageLive(_17); StorageLive(_18); - _18 = copy (*_15); -+ _18 = copy _10; ++ _18 = copy (*_9); StorageLive(_19); - _19 = copy (*_16); -- _17 = Eq(move _18, move _19); -+ _19 = copy _13; -+ _17 = Eq(copy _10, copy _13); ++ _19 = copy (*_12); + _17 = Eq(move _18, move _19); switchInt(move _17) -> [0: bb6, otherwise: bb5]; } @@ -166,10 +163,8 @@ StorageDead(_17); StorageDead(_16); StorageDead(_15); -- StorageDead(_13); -- StorageDead(_10); -+ nop; -+ nop; + StorageDead(_13); + StorageDead(_10); StorageDead(_8); StorageDead(_7); - StorageLive(_29); @@ -218,9 +213,8 @@ StorageLive(_33); StorageLive(_34); - StorageLive(_35); -- StorageLive(_36); -+ nop; + nop; + StorageLive(_36); StorageLive(_37); _37 = &(*_1); _36 = core::str::::as_ptr(move _37) -> [return: bb8, unwind continue]; @@ -230,9 +224,8 @@ StorageDead(_37); _35 = &_36; - StorageLive(_38); -- StorageLive(_39); -+ nop; + nop; + StorageLive(_39); StorageLive(_40); _40 = &(*_29); _39 = core::slice::::as_ptr(move _40) -> [return: bb9, unwind continue]; @@ -256,12 +249,11 @@ StorageLive(_43); StorageLive(_44); - _44 = copy (*_41); -+ _44 = copy _36; ++ _44 = copy (*_35); StorageLive(_45); - _45 = copy (*_42); -- _43 = Eq(move _44, move _45); -+ _45 = copy _39; -+ _43 = Eq(copy _36, copy _39); ++ _45 = copy (*_38); + _43 = Eq(move _44, move _45); switchInt(move _43) -> [0: bb11, otherwise: bb10]; } @@ -272,10 +264,8 @@ StorageDead(_43); StorageDead(_42); StorageDead(_41); -- StorageDead(_39); -- StorageDead(_36); -+ nop; -+ nop; + StorageDead(_39); + StorageDead(_36); StorageDead(_34); StorageDead(_33); _0 = const (); diff --git a/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-abort.diff b/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-abort.diff index 7a479bc55da75..e872e011542b3 100644 --- a/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-abort.diff @@ -758,39 +758,32 @@ StorageLive(_126); _126 = &_3; StorageLive(_127); -- StorageLive(_128); -- StorageLive(_129); -+ nop; -+ nop; + StorageLive(_128); + StorageLive(_129); _129 = copy (*_126); StorageLive(_130); _130 = copy _1; - _128 = Add(move _129, move _130); -+ _128 = Add(copy _129, copy _1); ++ _128 = Add(move _129, copy _1); StorageDead(_130); -- StorageDead(_129); -- _127 = opaque::(move _128) -> [return: bb35, unwind unreachable]; -+ nop; -+ _127 = opaque::(copy _128) -> [return: bb35, unwind unreachable]; + StorageDead(_129); + _127 = opaque::(move _128) -> [return: bb35, unwind unreachable]; } bb35: { -- StorageDead(_128); -+ nop; + StorageDead(_128); StorageDead(_127); StorageLive(_131); StorageLive(_132); StorageLive(_133); -- _133 = copy (*_126); -+ _133 = copy _129; + _133 = copy (*_126); StorageLive(_134); _134 = copy _1; - _132 = Add(move _133, move _134); -+ _132 = copy _128; ++ _132 = Add(move _133, copy _1); StorageDead(_134); StorageDead(_133); -- _131 = opaque::(move _132) -> [return: bb36, unwind unreachable]; -+ _131 = opaque::(copy _128) -> [return: bb36, unwind unreachable]; + _131 = opaque::(move _132) -> [return: bb36, unwind unreachable]; } bb36: { @@ -906,39 +899,32 @@ StorageLive(_163); _163 = &_3; StorageLive(_164); -- StorageLive(_165); -- StorageLive(_166); -+ nop; -+ nop; + StorageLive(_165); + StorageLive(_166); _166 = copy (*_163); StorageLive(_167); _167 = copy _1; - _165 = Add(move _166, move _167); -+ _165 = Add(copy _166, copy _1); ++ _165 = Add(move _166, copy _1); StorageDead(_167); -- StorageDead(_166); -- _164 = opaque::(move _165) -> [return: bb43, unwind unreachable]; -+ nop; -+ _164 = opaque::(copy _165) -> [return: bb43, unwind unreachable]; + StorageDead(_166); + _164 = opaque::(move _165) -> [return: bb43, unwind unreachable]; } bb43: { -- StorageDead(_165); -+ nop; + StorageDead(_165); StorageDead(_164); StorageLive(_168); StorageLive(_169); StorageLive(_170); -- _170 = copy (*_163); -+ _170 = copy _166; + _170 = copy (*_163); StorageLive(_171); _171 = copy _1; - _169 = Add(move _170, move _171); -+ _169 = copy _165; ++ _169 = Add(move _170, copy _1); StorageDead(_171); StorageDead(_170); -- _168 = opaque::(move _169) -> [return: bb44, unwind unreachable]; -+ _168 = opaque::(copy _165) -> [return: bb44, unwind unreachable]; + _168 = opaque::(move _169) -> [return: bb44, unwind unreachable]; } bb44: { diff --git a/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-unwind.diff b/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-unwind.diff index 3ca5238663c28..3996dab27a343 100644 --- a/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn.subexpression_elimination.GVN.panic-unwind.diff @@ -758,39 +758,32 @@ StorageLive(_126); _126 = &_3; StorageLive(_127); -- StorageLive(_128); -- StorageLive(_129); -+ nop; -+ nop; + StorageLive(_128); + StorageLive(_129); _129 = copy (*_126); StorageLive(_130); _130 = copy _1; - _128 = Add(move _129, move _130); -+ _128 = Add(copy _129, copy _1); ++ _128 = Add(move _129, copy _1); StorageDead(_130); -- StorageDead(_129); -- _127 = opaque::(move _128) -> [return: bb35, unwind continue]; -+ nop; -+ _127 = opaque::(copy _128) -> [return: bb35, unwind continue]; + StorageDead(_129); + _127 = opaque::(move _128) -> [return: bb35, unwind continue]; } bb35: { -- StorageDead(_128); -+ nop; + StorageDead(_128); StorageDead(_127); StorageLive(_131); StorageLive(_132); StorageLive(_133); -- _133 = copy (*_126); -+ _133 = copy _129; + _133 = copy (*_126); StorageLive(_134); _134 = copy _1; - _132 = Add(move _133, move _134); -+ _132 = copy _128; ++ _132 = Add(move _133, copy _1); StorageDead(_134); StorageDead(_133); -- _131 = opaque::(move _132) -> [return: bb36, unwind continue]; -+ _131 = opaque::(copy _128) -> [return: bb36, unwind continue]; + _131 = opaque::(move _132) -> [return: bb36, unwind continue]; } bb36: { @@ -906,39 +899,32 @@ StorageLive(_163); _163 = &_3; StorageLive(_164); -- StorageLive(_165); -- StorageLive(_166); -+ nop; -+ nop; + StorageLive(_165); + StorageLive(_166); _166 = copy (*_163); StorageLive(_167); _167 = copy _1; - _165 = Add(move _166, move _167); -+ _165 = Add(copy _166, copy _1); ++ _165 = Add(move _166, copy _1); StorageDead(_167); -- StorageDead(_166); -- _164 = opaque::(move _165) -> [return: bb43, unwind continue]; -+ nop; -+ _164 = opaque::(copy _165) -> [return: bb43, unwind continue]; + StorageDead(_166); + _164 = opaque::(move _165) -> [return: bb43, unwind continue]; } bb43: { -- StorageDead(_165); -+ nop; + StorageDead(_165); StorageDead(_164); StorageLive(_168); StorageLive(_169); StorageLive(_170); -- _170 = copy (*_163); -+ _170 = copy _166; + _170 = copy (*_163); StorageLive(_171); _171 = copy _1; - _169 = Add(move _170, move _171); -+ _169 = copy _165; ++ _169 = Add(move _170, copy _1); StorageDead(_171); StorageDead(_170); -- _168 = opaque::(move _169) -> [return: bb44, unwind continue]; -+ _168 = opaque::(copy _165) -> [return: bb44, unwind continue]; + _168 = opaque::(move _169) -> [return: bb44, unwind continue]; } bb44: { diff --git a/tests/mir-opt/gvn_uninhabited.f.GVN.panic-abort.diff b/tests/mir-opt/gvn_uninhabited.f.GVN.panic-abort.diff index 37b7b0d2c9db3..881b629803a34 100644 --- a/tests/mir-opt/gvn_uninhabited.f.GVN.panic-abort.diff +++ b/tests/mir-opt/gvn_uninhabited.f.GVN.panic-abort.diff @@ -17,16 +17,15 @@ StorageLive(_3); _5 = const f::promoted[0]; _3 = &(*_5); -- _2 = copy ((*_3).1: E); -+ _2 = copy ((*_5).1: E); - StorageLive(_1); -- _1 = copy ((_2 as A).1: u32); -+ _1 = const 0_u32; + _2 = copy ((*_3).1: E); +- StorageLive(_1); ++ nop; + _1 = copy ((_2 as A).1: u32); StorageDead(_3); StorageDead(_2); -- _0 = copy _1; -+ _0 = const 0_u32; - StorageDead(_1); + _0 = copy _1; +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/gvn_uninhabited.f.GVN.panic-unwind.diff b/tests/mir-opt/gvn_uninhabited.f.GVN.panic-unwind.diff index 37b7b0d2c9db3..881b629803a34 100644 --- a/tests/mir-opt/gvn_uninhabited.f.GVN.panic-unwind.diff +++ b/tests/mir-opt/gvn_uninhabited.f.GVN.panic-unwind.diff @@ -17,16 +17,15 @@ StorageLive(_3); _5 = const f::promoted[0]; _3 = &(*_5); -- _2 = copy ((*_3).1: E); -+ _2 = copy ((*_5).1: E); - StorageLive(_1); -- _1 = copy ((_2 as A).1: u32); -+ _1 = const 0_u32; + _2 = copy ((*_3).1: E); +- StorageLive(_1); ++ nop; + _1 = copy ((_2 as A).1: u32); StorageDead(_3); StorageDead(_2); -- _0 = copy _1; -+ _0 = const 0_u32; - StorageDead(_1); + _0 = copy _1; +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/pre-codegen/deref_nested_borrows.rs b/tests/mir-opt/pre-codegen/deref_nested_borrows.rs new file mode 100644 index 0000000000000..738cd981ae674 --- /dev/null +++ b/tests/mir-opt/pre-codegen/deref_nested_borrows.rs @@ -0,0 +1,24 @@ +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY + +fn src(x: &&u8) -> bool { + // CHECK-LABEL: fn src( + // CHECK-NOT: _0 = const true; + // CHECK: _0 = Eq({{.*}}, {{.*}}); + // CHECK-NOT: _0 = const true; + let y = **x; + unsafe { unknown() }; + **x == y +} + +#[inline(never)] +unsafe fn unknown() { + // CHECK-LABEL: fn unknown( +} + +fn main() { + // CHECK-LABEL: fn main( + src(&&0); +} + +// EMIT_MIR deref_nested_borrows.src.GVN.diff +// EMIT_MIR deref_nested_borrows.src.PreCodegen.after.mir diff --git a/tests/mir-opt/pre-codegen/deref_nested_borrows.src.GVN.panic-abort.diff b/tests/mir-opt/pre-codegen/deref_nested_borrows.src.GVN.panic-abort.diff new file mode 100644 index 0000000000000..993857f225a81 --- /dev/null +++ b/tests/mir-opt/pre-codegen/deref_nested_borrows.src.GVN.panic-abort.diff @@ -0,0 +1,42 @@ +- // MIR for `src` before GVN ++ // MIR for `src` after GVN + + fn src(_1: &&u8) -> bool { + debug x => _1; + let mut _0: bool; + let _2: u8; + let _3: (); + let mut _4: u8; + let mut _5: u8; + let mut _6: &u8; + let mut _7: &u8; + scope 1 { + debug y => _2; + } + + bb0: { +- StorageLive(_2); +- _6 = deref_copy (*_1); ++ nop; ++ _6 = copy (*_1); + _2 = copy (*_6); + _3 = unknown() -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageLive(_4); +- _7 = deref_copy (*_1); ++ _7 = copy (*_1); + _4 = copy (*_7); + StorageLive(_5); + _5 = copy _2; +- _0 = Eq(move _4, move _5); ++ _0 = Eq(move _4, copy _2); + StorageDead(_5); + StorageDead(_4); +- StorageDead(_2); ++ nop; + return; + } + } + diff --git a/tests/mir-opt/pre-codegen/deref_nested_borrows.src.GVN.panic-unwind.diff b/tests/mir-opt/pre-codegen/deref_nested_borrows.src.GVN.panic-unwind.diff new file mode 100644 index 0000000000000..d81bfa9310bc1 --- /dev/null +++ b/tests/mir-opt/pre-codegen/deref_nested_borrows.src.GVN.panic-unwind.diff @@ -0,0 +1,42 @@ +- // MIR for `src` before GVN ++ // MIR for `src` after GVN + + fn src(_1: &&u8) -> bool { + debug x => _1; + let mut _0: bool; + let _2: u8; + let _3: (); + let mut _4: u8; + let mut _5: u8; + let mut _6: &u8; + let mut _7: &u8; + scope 1 { + debug y => _2; + } + + bb0: { +- StorageLive(_2); +- _6 = deref_copy (*_1); ++ nop; ++ _6 = copy (*_1); + _2 = copy (*_6); + _3 = unknown() -> [return: bb1, unwind continue]; + } + + bb1: { + StorageLive(_4); +- _7 = deref_copy (*_1); ++ _7 = copy (*_1); + _4 = copy (*_7); + StorageLive(_5); + _5 = copy _2; +- _0 = Eq(move _4, move _5); ++ _0 = Eq(move _4, copy _2); + StorageDead(_5); + StorageDead(_4); +- StorageDead(_2); ++ nop; + return; + } + } + diff --git a/tests/mir-opt/pre-codegen/deref_nested_borrows.src.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/deref_nested_borrows.src.PreCodegen.after.panic-abort.mir new file mode 100644 index 0000000000000..23b1c3f3f43ad --- /dev/null +++ b/tests/mir-opt/pre-codegen/deref_nested_borrows.src.PreCodegen.after.panic-abort.mir @@ -0,0 +1,29 @@ +// MIR for `src` after PreCodegen + +fn src(_1: &&u8) -> bool { + debug x => _1; + let mut _0: bool; + let mut _2: &u8; + let _3: u8; + let _4: (); + let mut _5: &u8; + let mut _6: u8; + scope 1 { + debug y => _3; + } + + bb0: { + _2 = copy (*_1); + _3 = copy (*_2); + _4 = unknown() -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageLive(_6); + _5 = copy (*_1); + _6 = copy (*_5); + _0 = Eq(move _6, copy _3); + StorageDead(_6); + return; + } +} diff --git a/tests/mir-opt/pre-codegen/deref_nested_borrows.src.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/deref_nested_borrows.src.PreCodegen.after.panic-unwind.mir new file mode 100644 index 0000000000000..4c01e9464bf49 --- /dev/null +++ b/tests/mir-opt/pre-codegen/deref_nested_borrows.src.PreCodegen.after.panic-unwind.mir @@ -0,0 +1,29 @@ +// MIR for `src` after PreCodegen + +fn src(_1: &&u8) -> bool { + debug x => _1; + let mut _0: bool; + let mut _2: &u8; + let _3: u8; + let _4: (); + let mut _5: &u8; + let mut _6: u8; + scope 1 { + debug y => _3; + } + + bb0: { + _2 = copy (*_1); + _3 = copy (*_2); + _4 = unknown() -> [return: bb1, unwind continue]; + } + + bb1: { + StorageLive(_6); + _5 = copy (*_1); + _6 = copy (*_5); + _0 = Eq(move _6, copy _3); + StorageDead(_6); + return; + } +} diff --git a/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir index cbdd194afd3ab..5a269717f8297 100644 --- a/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir @@ -4,65 +4,70 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:7:25: 7:39}, _2 let mut _0: bool; let mut _3: &(usize, usize, usize, usize); let _4: &usize; - let _5: &usize; + let mut _5: &(usize, usize, usize, usize); let _6: &usize; - let _7: &usize; - let mut _8: &&usize; - let _9: &usize; - let mut _10: &&usize; - let mut _13: bool; - let mut _14: &&usize; - let _15: &usize; - let mut _16: &&usize; - let mut _19: bool; - let mut _20: &&usize; - let _21: &usize; - let mut _22: &&usize; - let mut _23: bool; - let mut _24: &&usize; - let _25: &usize; - let mut _26: &&usize; + let mut _7: &(usize, usize, usize, usize); + let _8: &usize; + let mut _9: &(usize, usize, usize, usize); + let _10: &usize; + let mut _11: &&usize; + let _12: &usize; + let mut _13: &&usize; + let mut _16: bool; + let mut _17: &&usize; + let _18: &usize; + let mut _19: &&usize; + let mut _22: bool; + let mut _23: &&usize; + let _24: &usize; + let mut _25: &&usize; + let mut _28: bool; + let mut _29: &&usize; + let _30: &usize; + let mut _31: &&usize; scope 1 { debug a => _4; - debug b => _5; - debug c => _6; - debug d => _7; + debug b => _6; + debug c => _8; + debug d => _10; scope 2 (inlined std::cmp::impls::::le) { - debug self => _8; - debug other => _10; + debug self => _11; + debug other => _13; scope 3 (inlined std::cmp::impls::::le) { debug self => _4; - debug other => _6; - let mut _11: usize; - let mut _12: usize; + debug other => _8; + let mut _14: usize; + let mut _15: usize; } } scope 4 (inlined std::cmp::impls::::le) { - debug self => _14; - debug other => _16; + debug self => _17; + debug other => _19; scope 5 (inlined std::cmp::impls::::le) { - debug self => _7; - debug other => _5; - let mut _17: usize; - let mut _18: usize; + debug self => _10; + debug other => _6; + let mut _20: usize; + let mut _21: usize; } } scope 6 (inlined std::cmp::impls::::le) { - debug self => _20; - debug other => _22; + debug self => _23; + debug other => _25; scope 7 (inlined std::cmp::impls::::le) { - debug self => _6; + debug self => _8; debug other => _4; + let mut _26: usize; + let mut _27: usize; } } scope 8 (inlined std::cmp::impls::::le) { - debug self => _24; - debug other => _26; + debug self => _29; + debug other => _31; scope 9 (inlined std::cmp::impls::::le) { - debug self => _5; - debug other => _7; - let mut _27: usize; - let mut _28: usize; + debug self => _6; + debug other => _10; + let mut _32: usize; + let mut _33: usize; } } } @@ -70,116 +75,129 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:7:25: 7:39}, _2 bb0: { _3 = copy (*_2); _4 = &((*_3).0: usize); - _5 = &((*_3).1: usize); - _6 = &((*_3).2: usize); - _7 = &((*_3).3: usize); + _5 = copy (*_2); + _6 = &((*_5).1: usize); + _7 = copy (*_2); + _8 = &((*_7).2: usize); + _9 = copy (*_2); + _10 = &((*_9).3: usize); + StorageLive(_16); + StorageLive(_11); + _11 = &_4; StorageLive(_13); - StorageLive(_8); - _8 = &_4; - StorageLive(_10); - StorageLive(_9); - _9 = copy _6; - _10 = &_9; - _11 = copy ((*_3).0: usize); - _12 = copy ((*_3).2: usize); - _13 = Le(copy _11, copy _12); - switchInt(move _13) -> [0: bb1, otherwise: bb2]; + StorageLive(_12); + _12 = copy _8; + _13 = &_12; + StorageLive(_14); + _14 = copy ((*_3).0: usize); + StorageLive(_15); + _15 = copy ((*_7).2: usize); + _16 = Le(move _14, move _15); + StorageDead(_15); + StorageDead(_14); + switchInt(move _16) -> [0: bb1, otherwise: bb2]; } bb1: { - StorageDead(_9); - StorageDead(_10); - StorageDead(_8); + StorageDead(_12); + StorageDead(_13); + StorageDead(_11); goto -> bb4; } bb2: { - StorageDead(_9); - StorageDead(_10); - StorageDead(_8); - StorageLive(_19); - StorageLive(_14); - _14 = &_7; - StorageLive(_16); - StorageLive(_15); - _15 = copy _5; - _16 = &_15; + StorageDead(_12); + StorageDead(_13); + StorageDead(_11); + StorageLive(_22); StorageLive(_17); - _17 = copy ((*_3).3: usize); + _17 = &_10; + StorageLive(_19); StorageLive(_18); - _18 = copy ((*_3).1: usize); - _19 = Le(move _17, move _18); - StorageDead(_18); - StorageDead(_17); - switchInt(move _19) -> [0: bb3, otherwise: bb8]; + _18 = copy _6; + _19 = &_18; + StorageLive(_20); + _20 = copy ((*_9).3: usize); + StorageLive(_21); + _21 = copy ((*_5).1: usize); + _22 = Le(move _20, move _21); + StorageDead(_21); + StorageDead(_20); + switchInt(move _22) -> [0: bb3, otherwise: bb8]; } bb3: { - StorageDead(_15); - StorageDead(_16); - StorageDead(_14); + StorageDead(_18); + StorageDead(_19); + StorageDead(_17); goto -> bb4; } bb4: { + StorageLive(_28); StorageLive(_23); - StorageLive(_20); - _20 = &_6; - StorageLive(_22); - StorageLive(_21); - _21 = copy _4; - _22 = &_21; - _23 = Le(copy _12, copy _11); - switchInt(move _23) -> [0: bb5, otherwise: bb6]; + _23 = &_8; + StorageLive(_25); + StorageLive(_24); + _24 = copy _4; + _25 = &_24; + StorageLive(_26); + _26 = copy ((*_7).2: usize); + StorageLive(_27); + _27 = copy ((*_3).0: usize); + _28 = Le(move _26, move _27); + StorageDead(_27); + StorageDead(_26); + switchInt(move _28) -> [0: bb5, otherwise: bb6]; } bb5: { - StorageDead(_21); - StorageDead(_22); - StorageDead(_20); + StorageDead(_24); + StorageDead(_25); + StorageDead(_23); _0 = const false; goto -> bb7; } bb6: { - StorageDead(_21); - StorageDead(_22); - StorageDead(_20); - StorageLive(_24); - _24 = &_5; - StorageLive(_26); - StorageLive(_25); - _25 = copy _7; - _26 = &_25; - StorageLive(_27); - _27 = copy ((*_3).1: usize); - StorageLive(_28); - _28 = copy ((*_3).3: usize); - _0 = Le(move _27, move _28); - StorageDead(_28); - StorageDead(_27); - StorageDead(_25); - StorageDead(_26); StorageDead(_24); + StorageDead(_25); + StorageDead(_23); + StorageLive(_29); + _29 = &_6; + StorageLive(_31); + StorageLive(_30); + _30 = copy _10; + _31 = &_30; + StorageLive(_32); + _32 = copy ((*_5).1: usize); + StorageLive(_33); + _33 = copy ((*_9).3: usize); + _0 = Le(move _32, move _33); + StorageDead(_33); + StorageDead(_32); + StorageDead(_30); + StorageDead(_31); + StorageDead(_29); goto -> bb7; } bb7: { - StorageDead(_23); + StorageDead(_28); goto -> bb9; } bb8: { - StorageDead(_15); - StorageDead(_16); - StorageDead(_14); + StorageDead(_18); + StorageDead(_19); + StorageDead(_17); _0 = const true; goto -> bb9; } bb9: { - StorageDead(_19); - StorageDead(_13); + StorageDead(_22); + StorageDead(_16); return; } } diff --git a/tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir index bc7a31d52199b..f93f7264dec20 100644 --- a/tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/slice_filter.variant_b-{closure#0}.PreCodegen.after.mir @@ -4,40 +4,46 @@ fn variant_b::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:11:25: 11:41}, let mut _0: bool; let mut _3: &(usize, usize, usize, usize); let _4: usize; - let _5: usize; + let mut _5: &(usize, usize, usize, usize); let _6: usize; - let _7: usize; - let mut _8: bool; - let mut _9: bool; - let mut _10: bool; + let mut _7: &(usize, usize, usize, usize); + let _8: usize; + let mut _9: &(usize, usize, usize, usize); + let _10: usize; + let mut _11: bool; + let mut _12: bool; + let mut _13: bool; scope 1 { debug a => _4; - debug b => _5; - debug c => _6; - debug d => _7; + debug b => _6; + debug c => _8; + debug d => _10; } bb0: { _3 = copy (*_2); _4 = copy ((*_3).0: usize); - _5 = copy ((*_3).1: usize); - _6 = copy ((*_3).2: usize); - _7 = copy ((*_3).3: usize); - StorageLive(_8); - _8 = Le(copy _4, copy _6); - switchInt(move _8) -> [0: bb2, otherwise: bb1]; + _5 = copy (*_2); + _6 = copy ((*_5).1: usize); + _7 = copy (*_2); + _8 = copy ((*_7).2: usize); + _9 = copy (*_2); + _10 = copy ((*_9).3: usize); + StorageLive(_11); + _11 = Le(copy _4, copy _8); + switchInt(move _11) -> [0: bb2, otherwise: bb1]; } bb1: { - StorageLive(_9); - _9 = Le(copy _7, copy _5); - switchInt(move _9) -> [0: bb2, otherwise: bb6]; + StorageLive(_12); + _12 = Le(copy _10, copy _6); + switchInt(move _12) -> [0: bb2, otherwise: bb6]; } bb2: { - StorageLive(_10); - _10 = Le(copy _6, copy _4); - switchInt(move _10) -> [0: bb3, otherwise: bb4]; + StorageLive(_13); + _13 = Le(copy _8, copy _4); + switchInt(move _13) -> [0: bb3, otherwise: bb4]; } bb3: { @@ -46,12 +52,12 @@ fn variant_b::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:11:25: 11:41}, } bb4: { - _0 = Le(copy _5, copy _7); + _0 = Le(copy _6, copy _10); goto -> bb5; } bb5: { - StorageDead(_10); + StorageDead(_13); goto -> bb7; } @@ -61,8 +67,8 @@ fn variant_b::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:11:25: 11:41}, } bb7: { - StorageDead(_9); - StorageDead(_8); + StorageDead(_12); + StorageDead(_11); return; } }