From b9dbb81b5e4f62be117fd196723a85e45b84341d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannis=20Christopher=20K=C3=B6hl?= Date: Fri, 7 Oct 2022 01:17:43 +0200 Subject: [PATCH] Improve example used for SB tests --- .../ref_with_sb.main.DataflowConstProp.diff | 30 ++++++++++++------- .../dataflow-const-prop/ref_with_sb.rs | 4 +++ ...ref_without_sb.main.DataflowConstProp.diff | 28 +++++++++++------ .../dataflow-const-prop/ref_without_sb.rs | 4 +++ 4 files changed, 47 insertions(+), 19 deletions(-) diff --git a/src/test/mir-opt/dataflow-const-prop/ref_with_sb.main.DataflowConstProp.diff b/src/test/mir-opt/dataflow-const-prop/ref_with_sb.main.DataflowConstProp.diff index 6a9de6af8c5..81aa0a1a93d 100644 --- a/src/test/mir-opt/dataflow-const-prop/ref_with_sb.main.DataflowConstProp.diff +++ b/src/test/mir-opt/dataflow-const-prop/ref_with_sb.main.DataflowConstProp.diff @@ -7,11 +7,12 @@ let _2: (); // in scope 0 at $DIR/ref_with_sb.rs:+2:5: +2:15 let mut _3: &i32; // in scope 0 at $DIR/ref_with_sb.rs:+2:12: +2:14 let _4: &i32; // in scope 0 at $DIR/ref_with_sb.rs:+2:12: +2:14 + let _5: (); // in scope 0 at $DIR/ref_with_sb.rs:+4:5: +4:20 scope 1 { debug a => _1; // in scope 1 at $DIR/ref_with_sb.rs:+1:9: +1:14 - let _5: i32; // in scope 1 at $DIR/ref_with_sb.rs:+6:9: +6:10 + let _6: i32; // in scope 1 at $DIR/ref_with_sb.rs:+7:9: +7:10 scope 2 { - debug b => _5; // in scope 2 at $DIR/ref_with_sb.rs:+6:9: +6:10 + debug b => _6; // in scope 2 at $DIR/ref_with_sb.rs:+7:9: +7:10 } } @@ -25,7 +26,7 @@ _3 = &(*_4); // scope 1 at $DIR/ref_with_sb.rs:+2:12: +2:14 _2 = escape::(move _3) -> bb1; // scope 1 at $DIR/ref_with_sb.rs:+2:5: +2:15 // mir::Constant - // + span: $DIR/ref_with_sb.rs:10:5: 10:11 + // + span: $DIR/ref_with_sb.rs:13:5: 13:11 // + literal: Const { ty: for<'a> fn(&'a i32) {escape::}, val: Value() } } @@ -34,13 +35,22 @@ StorageDead(_4); // scope 1 at $DIR/ref_with_sb.rs:+2:15: +2:16 StorageDead(_2); // scope 1 at $DIR/ref_with_sb.rs:+2:15: +2:16 _1 = const 1_i32; // scope 1 at $DIR/ref_with_sb.rs:+3:5: +3:10 - StorageLive(_5); // scope 1 at $DIR/ref_with_sb.rs:+6:9: +6:10 -- _5 = _1; // scope 1 at $DIR/ref_with_sb.rs:+6:13: +6:14 -+ _5 = const 1_i32; // scope 1 at $DIR/ref_with_sb.rs:+6:13: +6:14 - _0 = const (); // scope 0 at $DIR/ref_with_sb.rs:+0:11: +7:2 - StorageDead(_5); // scope 1 at $DIR/ref_with_sb.rs:+7:1: +7:2 - StorageDead(_1); // scope 0 at $DIR/ref_with_sb.rs:+7:1: +7:2 - return; // scope 0 at $DIR/ref_with_sb.rs:+7:2: +7:2 + StorageLive(_5); // scope 1 at $DIR/ref_with_sb.rs:+4:5: +4:20 + _5 = some_function() -> bb2; // scope 1 at $DIR/ref_with_sb.rs:+4:5: +4:20 + // mir::Constant + // + span: $DIR/ref_with_sb.rs:15:5: 15:18 + // + literal: Const { ty: fn() {some_function}, val: Value() } + } + + bb2: { + StorageDead(_5); // scope 1 at $DIR/ref_with_sb.rs:+4:20: +4:21 + StorageLive(_6); // scope 1 at $DIR/ref_with_sb.rs:+7:9: +7:10 +- _6 = _1; // scope 1 at $DIR/ref_with_sb.rs:+7:13: +7:14 ++ _6 = const 1_i32; // scope 1 at $DIR/ref_with_sb.rs:+7:13: +7:14 + _0 = const (); // scope 0 at $DIR/ref_with_sb.rs:+0:11: +8:2 + StorageDead(_6); // scope 1 at $DIR/ref_with_sb.rs:+8:1: +8:2 + StorageDead(_1); // scope 0 at $DIR/ref_with_sb.rs:+8:1: +8:2 + return; // scope 0 at $DIR/ref_with_sb.rs:+8:2: +8:2 } } diff --git a/src/test/mir-opt/dataflow-const-prop/ref_with_sb.rs b/src/test/mir-opt/dataflow-const-prop/ref_with_sb.rs index 05f18dab4cd..060aa6ab794 100644 --- a/src/test/mir-opt/dataflow-const-prop/ref_with_sb.rs +++ b/src/test/mir-opt/dataflow-const-prop/ref_with_sb.rs @@ -4,11 +4,15 @@ #[inline(never)] fn escape(x: &T) {} +#[inline(never)] +fn some_function() {} + // EMIT_MIR ref_with_sb.main.DataflowConstProp.diff fn main() { let mut a = 0; escape(&a); a = 1; + some_function(); // With `-Zunsound-mir-opt`, this should be propagated // (because we assume Stacked Borrows). let b = a; diff --git a/src/test/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.diff b/src/test/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.diff index 66b05cdb7c1..dc6a6a8a759 100644 --- a/src/test/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.diff +++ b/src/test/mir-opt/dataflow-const-prop/ref_without_sb.main.DataflowConstProp.diff @@ -7,11 +7,12 @@ let _2: (); // in scope 0 at $DIR/ref_without_sb.rs:+2:5: +2:15 let mut _3: &i32; // in scope 0 at $DIR/ref_without_sb.rs:+2:12: +2:14 let _4: &i32; // in scope 0 at $DIR/ref_without_sb.rs:+2:12: +2:14 + let _5: (); // in scope 0 at $DIR/ref_without_sb.rs:+4:5: +4:20 scope 1 { debug a => _1; // in scope 1 at $DIR/ref_without_sb.rs:+1:9: +1:14 - let _5: i32; // in scope 1 at $DIR/ref_without_sb.rs:+6:9: +6:10 + let _6: i32; // in scope 1 at $DIR/ref_without_sb.rs:+7:9: +7:10 scope 2 { - debug b => _5; // in scope 2 at $DIR/ref_without_sb.rs:+6:9: +6:10 + debug b => _6; // in scope 2 at $DIR/ref_without_sb.rs:+7:9: +7:10 } } @@ -25,7 +26,7 @@ _3 = &(*_4); // scope 1 at $DIR/ref_without_sb.rs:+2:12: +2:14 _2 = escape::(move _3) -> bb1; // scope 1 at $DIR/ref_without_sb.rs:+2:5: +2:15 // mir::Constant - // + span: $DIR/ref_without_sb.rs:9:5: 9:11 + // + span: $DIR/ref_without_sb.rs:12:5: 12:11 // + literal: Const { ty: for<'a> fn(&'a i32) {escape::}, val: Value() } } @@ -34,12 +35,21 @@ StorageDead(_4); // scope 1 at $DIR/ref_without_sb.rs:+2:15: +2:16 StorageDead(_2); // scope 1 at $DIR/ref_without_sb.rs:+2:15: +2:16 _1 = const 1_i32; // scope 1 at $DIR/ref_without_sb.rs:+3:5: +3:10 - StorageLive(_5); // scope 1 at $DIR/ref_without_sb.rs:+6:9: +6:10 - _5 = _1; // scope 1 at $DIR/ref_without_sb.rs:+6:13: +6:14 - _0 = const (); // scope 0 at $DIR/ref_without_sb.rs:+0:11: +7:2 - StorageDead(_5); // scope 1 at $DIR/ref_without_sb.rs:+7:1: +7:2 - StorageDead(_1); // scope 0 at $DIR/ref_without_sb.rs:+7:1: +7:2 - return; // scope 0 at $DIR/ref_without_sb.rs:+7:2: +7:2 + StorageLive(_5); // scope 1 at $DIR/ref_without_sb.rs:+4:5: +4:20 + _5 = some_function() -> bb2; // scope 1 at $DIR/ref_without_sb.rs:+4:5: +4:20 + // mir::Constant + // + span: $DIR/ref_without_sb.rs:14:5: 14:18 + // + literal: Const { ty: fn() {some_function}, val: Value() } + } + + bb2: { + StorageDead(_5); // scope 1 at $DIR/ref_without_sb.rs:+4:20: +4:21 + StorageLive(_6); // scope 1 at $DIR/ref_without_sb.rs:+7:9: +7:10 + _6 = _1; // scope 1 at $DIR/ref_without_sb.rs:+7:13: +7:14 + _0 = const (); // scope 0 at $DIR/ref_without_sb.rs:+0:11: +8:2 + StorageDead(_6); // scope 1 at $DIR/ref_without_sb.rs:+8:1: +8:2 + StorageDead(_1); // scope 0 at $DIR/ref_without_sb.rs:+8:1: +8:2 + return; // scope 0 at $DIR/ref_without_sb.rs:+8:2: +8:2 } } diff --git a/src/test/mir-opt/dataflow-const-prop/ref_without_sb.rs b/src/test/mir-opt/dataflow-const-prop/ref_without_sb.rs index 4ef027a9b4d..4789eb69cda 100644 --- a/src/test/mir-opt/dataflow-const-prop/ref_without_sb.rs +++ b/src/test/mir-opt/dataflow-const-prop/ref_without_sb.rs @@ -3,11 +3,15 @@ #[inline(never)] fn escape(x: &T) {} +#[inline(never)] +fn some_function() {} + // EMIT_MIR ref_without_sb.main.DataflowConstProp.diff fn main() { let mut a = 0; escape(&a); a = 1; + some_function(); // Without `-Zunsound-mir-opt`, this should not be propagated // (because we do not assume Stacked Borrows). let b = a;