Skip to content

Commit 68ff5f0

Browse files
olioli-obk
authored andcommitted
Stop optimizing promoteds
1 parent 9a22f99 commit 68ff5f0

8 files changed

+62
-63
lines changed

compiler/rustc_mir/src/transform/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,6 @@ fn promoted_mir<'tcx>(
510510

511511
for body in &mut promoted {
512512
run_post_borrowck_cleanup_passes(tcx, body);
513-
run_optimization_passes(tcx, body);
514513
}
515514

516515
debug_assert!(!promoted.has_free_regions(), "Free regions in promoted MIR");

src/test/mir-opt/const-promotion-extern-static.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ extern "C" {
55
static Y: i32 = 42;
66

77
// EMIT_MIR const_promotion_extern_static.BAR.PromoteTemps.diff
8-
// EMIT_MIR const_promotion_extern_static.BAR-promoted[0].ConstProp.after.mir
8+
// EMIT_MIR const_promotion_extern_static.BAR-promoted[0].SimplifyCfg-elaborate-drops.after.mir
99
static mut BAR: *const &i32 = [&Y].as_ptr();
1010

1111
// EMIT_MIR const_promotion_extern_static.FOO.PromoteTemps.diff
12-
// EMIT_MIR const_promotion_extern_static.FOO-promoted[0].ConstProp.after.mir
12+
// EMIT_MIR const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-elaborate-drops.after.mir
1313
static mut FOO: *const &i32 = [unsafe { &X }].as_ptr();
1414

1515
// EMIT_MIR const_promotion_extern_static.BOP.mir_map.0.mir

src/test/mir-opt/const_allocation.main.ConstProp.after.32bit.mir

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,42 +24,42 @@ fn main() -> () {
2424
}
2525

2626
alloc0 (static: FOO, size: 8, align: 4) {
27-
╾─alloc14─╼ 03 00 00 00 │ ╾──╼....
27+
╾─alloc17─╼ 03 00 00 00 │ ╾──╼....
2828
}
2929

30-
alloc14 (size: 48, align: 4) {
30+
alloc17 (size: 48, align: 4) {
3131
0x00 │ 00 00 00 00 __ __ __ __ ╾─alloc4──╼ 00 00 00 00 │ ....░░░░╾──╼....
32-
0x10 │ 00 00 00 00 __ __ __ __ ╾─alloc7──╼ 02 00 00 00 │ ....░░░░╾──╼....
33-
0x20 │ 01 00 00 00 2a 00 00 00 ╾─alloc11─╼ 03 00 00 00 │ ....*...╾──╼....
32+
0x10 │ 00 00 00 00 __ __ __ __ ╾─alloc8──╼ 02 00 00 00 │ ....░░░░╾──╼....
33+
0x20 │ 01 00 00 00 2a 00 00 00 ╾─alloc13─╼ 03 00 00 00 │ ....*...╾──╼....
3434
}
3535

3636
alloc4 (size: 0, align: 4) {}
3737

38-
alloc7 (size: 16, align: 4) {
39-
╾─alloc6──╼ 03 00 00 00 ╾─alloc8──╼ 03 00 00 00 │ ╾──╼....╾──╼....
38+
alloc8 (size: 16, align: 4) {
39+
╾─alloc7──╼ 03 00 00 00 ╾─alloc9──╼ 03 00 00 00 │ ╾──╼....╾──╼....
4040
}
4141

42-
alloc6 (size: 3, align: 1) {
42+
alloc7 (size: 3, align: 1) {
4343
66 6f 6f │ foo
4444
}
4545

46-
alloc8 (size: 3, align: 1) {
46+
alloc9 (size: 3, align: 1) {
4747
62 61 72 │ bar
4848
}
4949

50-
alloc11 (size: 24, align: 4) {
51-
0x00 │ ╾─alloc10─╼ 03 00 00 00 ╾─alloc12─╼ 03 00 00 00 │ ╾──╼....╾──╼....
52-
0x10 │ ╾─alloc13─╼ 04 00 00 00 │ ╾──╼....
50+
alloc13 (size: 24, align: 4) {
51+
0x00 │ ╾─alloc12─╼ 03 00 00 00 ╾─alloc14─╼ 03 00 00 00 │ ╾──╼....╾──╼....
52+
0x10 │ ╾─alloc15─╼ 04 00 00 00 │ ╾──╼....
5353
}
5454

55-
alloc10 (size: 3, align: 1) {
55+
alloc12 (size: 3, align: 1) {
5656
6d 65 68 │ meh
5757
}
5858

59-
alloc12 (size: 3, align: 1) {
59+
alloc14 (size: 3, align: 1) {
6060
6d 6f 70 │ mop
6161
}
6262

63-
alloc13 (size: 4, align: 1) {
63+
alloc15 (size: 4, align: 1) {
6464
6d c3 b6 70 │ m..p
6565
}

src/test/mir-opt/const_allocation.main.ConstProp.after.64bit.mir

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,46 +24,46 @@ fn main() -> () {
2424
}
2525

2626
alloc0 (static: FOO, size: 16, align: 8) {
27-
╾───────alloc14───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........
27+
╾───────alloc17───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........
2828
}
2929

30-
alloc14 (size: 72, align: 8) {
30+
alloc17 (size: 72, align: 8) {
3131
0x00 │ 00 00 00 00 __ __ __ __ ╾───────alloc4────────╼ │ ....░░░░╾──────╼
3232
0x10 │ 00 00 00 00 00 00 00 00 00 00 00 00 __ __ __ __ │ ............░░░░
33-
0x20 │ ╾───────alloc7────────╼ 02 00 00 00 00 00 00 00 │ ╾──────╼........
34-
0x30 │ 01 00 00 00 2a 00 00 00 ╾───────alloc11───────╼ │ ....*...╾──────╼
33+
0x20 │ ╾───────alloc8────────╼ 02 00 00 00 00 00 00 00 │ ╾──────╼........
34+
0x30 │ 01 00 00 00 2a 00 00 00 ╾───────alloc13───────╼ │ ....*...╾──────╼
3535
0x40 │ 03 00 00 00 00 00 00 00 │ ........
3636
}
3737

3838
alloc4 (size: 0, align: 8) {}
3939

40-
alloc7 (size: 32, align: 8) {
41-
0x00 │ ╾───────alloc6────────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........
42-
0x10 │ ╾───────alloc8────────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........
40+
alloc8 (size: 32, align: 8) {
41+
0x00 │ ╾───────alloc7────────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........
42+
0x10 │ ╾───────alloc9────────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........
4343
}
4444

45-
alloc6 (size: 3, align: 1) {
45+
alloc7 (size: 3, align: 1) {
4646
66 6f 6f │ foo
4747
}
4848

49-
alloc8 (size: 3, align: 1) {
49+
alloc9 (size: 3, align: 1) {
5050
62 61 72 │ bar
5151
}
5252

53-
alloc11 (size: 48, align: 8) {
54-
0x00 │ ╾───────alloc10───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........
55-
0x10 │ ╾───────alloc12───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........
56-
0x20 │ ╾───────alloc13───────╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........
53+
alloc13 (size: 48, align: 8) {
54+
0x00 │ ╾───────alloc12───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........
55+
0x10 │ ╾───────alloc14───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........
56+
0x20 │ ╾───────alloc15───────╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........
5757
}
5858

59-
alloc10 (size: 3, align: 1) {
59+
alloc12 (size: 3, align: 1) {
6060
6d 65 68 │ meh
6161
}
6262

63-
alloc12 (size: 3, align: 1) {
63+
alloc14 (size: 3, align: 1) {
6464
6d 6f 70 │ mop
6565
}
6666

67-
alloc13 (size: 4, align: 1) {
67+
alloc15 (size: 4, align: 1) {
6868
6d c3 b6 70 │ m..p
6969
}

src/test/mir-opt/const_allocation2.main.ConstProp.after.32bit.mir

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,41 +24,41 @@ fn main() -> () {
2424
}
2525

2626
alloc0 (static: FOO, size: 8, align: 4) {
27-
╾─alloc20─╼ 03 00 00 00 │ ╾──╼....
27+
╾─alloc23─╼ 03 00 00 00 │ ╾──╼....
2828
}
2929

30-
alloc20 (size: 48, align: 4) {
30+
alloc23 (size: 48, align: 4) {
3131
0x00 │ 00 00 00 00 __ __ __ __ ╾─alloc8──╼ 00 00 00 00 │ ....░░░░╾──╼....
32-
0x10 │ 00 00 00 00 __ __ __ __ ╾─alloc12─╼ 02 00 00 00 │ ....░░░░╾──╼....
33-
0x20 │ 01 00 00 00 2a 00 00 00 ╾─alloc19─╼ 03 00 00 00 │ ....*...╾──╼....
32+
0x10 │ 00 00 00 00 __ __ __ __ ╾─alloc13─╼ 02 00 00 00 │ ....░░░░╾──╼....
33+
0x20 │ 01 00 00 00 2a 00 00 00 ╾─alloc21─╼ 03 00 00 00 │ ....*...╾──╼....
3434
}
3535

3636
alloc8 (size: 0, align: 4) {}
3737

38-
alloc12 (size: 8, align: 4) {
39-
╾─alloc10─╼ ╾─alloc11─╼ │ ╾──╼╾──╼
38+
alloc13 (size: 8, align: 4) {
39+
╾─alloc11─╼ ╾─alloc12─╼ │ ╾──╼╾──╼
4040
}
4141

42-
alloc10 (size: 1, align: 1) {
42+
alloc11 (size: 1, align: 1) {
4343
05 │ .
4444
}
4545

46-
alloc11 (size: 1, align: 1) {
46+
alloc12 (size: 1, align: 1) {
4747
06 │ .
4848
}
4949

50-
alloc19 (size: 12, align: 4) {
51-
╾─a15+0x3─╼ ╾─alloc16─╼ ╾─a18+0x2─╼ │ ╾──╼╾──╼╾──╼
50+
alloc21 (size: 12, align: 4) {
51+
╾─a17+0x3─╼ ╾─alloc18─╼ ╾─a20+0x2─╼ │ ╾──╼╾──╼╾──╼
5252
}
5353

54-
alloc15 (size: 4, align: 1) {
54+
alloc17 (size: 4, align: 1) {
5555
2a 45 15 6f │ *E.o
5656
}
5757

58-
alloc16 (size: 1, align: 1) {
58+
alloc18 (size: 1, align: 1) {
5959
2a │ *
6060
}
6161

62-
alloc18 (size: 4, align: 1) {
62+
alloc20 (size: 4, align: 1) {
6363
2a 45 15 6f │ *E.o
6464
}

src/test/mir-opt/const_allocation2.main.ConstProp.after.64bit.mir

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,44 +24,44 @@ fn main() -> () {
2424
}
2525

2626
alloc0 (static: FOO, size: 16, align: 8) {
27-
╾───────alloc20───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........
27+
╾───────alloc23───────╼ 03 00 00 00 00 00 00 00 │ ╾──────╼........
2828
}
2929

30-
alloc20 (size: 72, align: 8) {
30+
alloc23 (size: 72, align: 8) {
3131
0x00 │ 00 00 00 00 __ __ __ __ ╾───────alloc8────────╼ │ ....░░░░╾──────╼
3232
0x10 │ 00 00 00 00 00 00 00 00 00 00 00 00 __ __ __ __ │ ............░░░░
33-
0x20 │ ╾───────alloc12───────╼ 02 00 00 00 00 00 00 00 │ ╾──────╼........
34-
0x30 │ 01 00 00 00 2a 00 00 00 ╾───────alloc19───────╼ │ ....*...╾──────╼
33+
0x20 │ ╾───────alloc13───────╼ 02 00 00 00 00 00 00 00 │ ╾──────╼........
34+
0x30 │ 01 00 00 00 2a 00 00 00 ╾───────alloc21───────╼ │ ....*...╾──────╼
3535
0x40 │ 03 00 00 00 00 00 00 00 │ ........
3636
}
3737

3838
alloc8 (size: 0, align: 8) {}
3939

40-
alloc12 (size: 16, align: 8) {
41-
╾───────alloc10───────╼ ╾───────alloc11───────╼ │ ╾──────╼╾──────╼
40+
alloc13 (size: 16, align: 8) {
41+
╾───────alloc11───────╼ ╾───────alloc12───────╼ │ ╾──────╼╾──────╼
4242
}
4343

44-
alloc10 (size: 1, align: 1) {
44+
alloc11 (size: 1, align: 1) {
4545
05 │ .
4646
}
4747

48-
alloc11 (size: 1, align: 1) {
48+
alloc12 (size: 1, align: 1) {
4949
06 │ .
5050
}
5151

52-
alloc19 (size: 24, align: 8) {
53-
0x00 │ ╾─────alloc15+0x3─────╼ ╾───────alloc16───────╼ │ ╾──────╼╾──────╼
54-
0x10 │ ╾─────alloc18+0x2─────╼ │ ╾──────╼
52+
alloc21 (size: 24, align: 8) {
53+
0x00 │ ╾─────alloc17+0x3─────╼ ╾───────alloc18───────╼ │ ╾──────╼╾──────╼
54+
0x10 │ ╾─────alloc20+0x2─────╼ │ ╾──────╼
5555
}
5656

57-
alloc15 (size: 4, align: 1) {
57+
alloc17 (size: 4, align: 1) {
5858
2a 45 15 6f │ *E.o
5959
}
6060

61-
alloc16 (size: 1, align: 1) {
61+
alloc18 (size: 1, align: 1) {
6262
2a │ *
6363
}
6464

65-
alloc18 (size: 4, align: 1) {
65+
alloc20 (size: 4, align: 1) {
6666
2a 45 15 6f │ *E.o
6767
}

src/test/mir-opt/const_promotion_extern_static.BAR-promoted[0].ConstProp.after.mir renamed to src/test/mir-opt/const_promotion_extern_static.BAR-promoted[0].SimplifyCfg-elaborate-drops.after.mir

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// MIR for `BAR::promoted[0]` after ConstProp
1+
// MIR for `BAR::promoted[0]` after SimplifyCfg-elaborate-drops
22

33
promoted[0] in BAR: &[&i32; 1] = {
44
let mut _0: &[&i32; 1]; // return place in scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:35
@@ -14,7 +14,7 @@ promoted[0] in BAR: &[&i32; 1] = {
1414
// mir::Constant
1515
// + span: $DIR/const-promotion-extern-static.rs:9:33: 9:34
1616
// + literal: Const { ty: &i32, val: Value(Scalar(alloc0)) }
17-
_2 = _3; // scope 0 at $DIR/const-promotion-extern-static.rs:9:32: 9:34
17+
_2 = &(*_3); // scope 0 at $DIR/const-promotion-extern-static.rs:9:32: 9:34
1818
_1 = [move _2]; // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:35
1919
_0 = &_1; // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:35
2020
return; // scope 0 at $DIR/const-promotion-extern-static.rs:9:31: 9:35

src/test/mir-opt/const_promotion_extern_static.FOO-promoted[0].ConstProp.after.mir renamed to src/test/mir-opt/const_promotion_extern_static.FOO-promoted[0].SimplifyCfg-elaborate-drops.after.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// MIR for `FOO::promoted[0]` after ConstProp
1+
// MIR for `FOO::promoted[0]` after SimplifyCfg-elaborate-drops
22

33
promoted[0] in FOO: &[&i32; 1] = {
44
let mut _0: &[&i32; 1]; // return place in scope 0 at $DIR/const-promotion-extern-static.rs:13:31: 13:46

0 commit comments

Comments
 (0)