Skip to content

Commit 2cc0ee6

Browse files
cjgillotRalfJung
authored andcommitted
Add test.
1 parent 7db7489 commit 2cc0ee6

5 files changed

+154
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// EMIT_MIR_FOR_EACH_PANIC_STRATEGY
2+
3+
fn src(x: &&u8) -> bool {
4+
// CHECK-LABEL: fn src(
5+
// CHECK: _0 = const true;
6+
let y = **x;
7+
unsafe { unknown() };
8+
**x == y
9+
}
10+
11+
#[inline(never)]
12+
unsafe fn unknown() {
13+
// CHECK-LABEL: fn unknown(
14+
}
15+
16+
fn main() {
17+
// CHECK-LABEL: fn main(
18+
src(&&0);
19+
}
20+
21+
// EMIT_MIR deref_nested_borrows.src.GVN.diff
22+
// EMIT_MIR deref_nested_borrows.src.PreCodegen.after.mir
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
- // MIR for `src` before GVN
2+
+ // MIR for `src` after GVN
3+
4+
fn src(_1: &&u8) -> bool {
5+
debug x => _1;
6+
let mut _0: bool;
7+
let _2: u8;
8+
let _3: ();
9+
let mut _4: u8;
10+
let mut _5: u8;
11+
let mut _6: &u8;
12+
let mut _7: &u8;
13+
scope 1 {
14+
debug y => _2;
15+
}
16+
17+
bb0: {
18+
- StorageLive(_2);
19+
- _6 = deref_copy (*_1);
20+
+ nop;
21+
+ _6 = copy (*_1);
22+
_2 = copy (*_6);
23+
_3 = unknown() -> [return: bb1, unwind unreachable];
24+
}
25+
26+
bb1: {
27+
StorageLive(_4);
28+
- _7 = deref_copy (*_1);
29+
- _4 = copy (*_7);
30+
+ _7 = copy _6;
31+
+ _4 = copy _2;
32+
StorageLive(_5);
33+
_5 = copy _2;
34+
- _0 = Eq(move _4, move _5);
35+
+ _0 = const true;
36+
StorageDead(_5);
37+
StorageDead(_4);
38+
- StorageDead(_2);
39+
+ nop;
40+
return;
41+
}
42+
}
43+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
- // MIR for `src` before GVN
2+
+ // MIR for `src` after GVN
3+
4+
fn src(_1: &&u8) -> bool {
5+
debug x => _1;
6+
let mut _0: bool;
7+
let _2: u8;
8+
let _3: ();
9+
let mut _4: u8;
10+
let mut _5: u8;
11+
let mut _6: &u8;
12+
let mut _7: &u8;
13+
scope 1 {
14+
debug y => _2;
15+
}
16+
17+
bb0: {
18+
- StorageLive(_2);
19+
- _6 = deref_copy (*_1);
20+
+ nop;
21+
+ _6 = copy (*_1);
22+
_2 = copy (*_6);
23+
_3 = unknown() -> [return: bb1, unwind continue];
24+
}
25+
26+
bb1: {
27+
StorageLive(_4);
28+
- _7 = deref_copy (*_1);
29+
- _4 = copy (*_7);
30+
+ _7 = copy _6;
31+
+ _4 = copy _2;
32+
StorageLive(_5);
33+
_5 = copy _2;
34+
- _0 = Eq(move _4, move _5);
35+
+ _0 = const true;
36+
StorageDead(_5);
37+
StorageDead(_4);
38+
- StorageDead(_2);
39+
+ nop;
40+
return;
41+
}
42+
}
43+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// MIR for `src` after PreCodegen
2+
3+
fn src(_1: &&u8) -> bool {
4+
debug x => _1;
5+
let mut _0: bool;
6+
let mut _2: &u8;
7+
let _3: u8;
8+
let _4: ();
9+
scope 1 {
10+
debug y => _3;
11+
}
12+
13+
bb0: {
14+
_2 = copy (*_1);
15+
_3 = copy (*_2);
16+
_4 = unknown() -> [return: bb1, unwind unreachable];
17+
}
18+
19+
bb1: {
20+
_0 = const true;
21+
return;
22+
}
23+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// MIR for `src` after PreCodegen
2+
3+
fn src(_1: &&u8) -> bool {
4+
debug x => _1;
5+
let mut _0: bool;
6+
let mut _2: &u8;
7+
let _3: u8;
8+
let _4: ();
9+
scope 1 {
10+
debug y => _3;
11+
}
12+
13+
bb0: {
14+
_2 = copy (*_1);
15+
_3 = copy (*_2);
16+
_4 = unknown() -> [return: bb1, unwind continue];
17+
}
18+
19+
bb1: {
20+
_0 = const true;
21+
return;
22+
}
23+
}

0 commit comments

Comments
 (0)