Improve example used for SB tests

This commit is contained in:
Jannis Christopher Köhl 2022-10-07 01:17:43 +02:00
parent 7a52e7350e
commit b9dbb81b5e
4 changed files with 47 additions and 19 deletions

View File

@ -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::<i32>(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::<i32>}, val: Value(<ZST>) }
}
@ -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(<ZST>) }
}
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
}
}

View File

@ -4,11 +4,15 @@
#[inline(never)]
fn escape<T>(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;

View File

@ -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::<i32>(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::<i32>}, val: Value(<ZST>) }
}
@ -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(<ZST>) }
}
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
}
}

View File

@ -3,11 +3,15 @@
#[inline(never)]
fn escape<T>(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;