Skip to content

Commit 11e9fef

Browse files
committed
restrict to coroutines again for perf
1 parent 26833b6 commit 11e9fef

30 files changed

Lines changed: 738 additions & 394 deletions

File tree

compiler/rustc_mir_transform/src/remove_dead_drops.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ impl<'tcx> crate::MirPass<'tcx> for RemoveDeadDrops {
1414
}
1515

1616
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
17+
if body.coroutine.is_none() {
18+
return;
19+
}
20+
1721
let move_data = MoveData::gather_moves(body, tcx, |_| true);
1822

1923
let mut maybe_init_cursor = MaybeInitializedPlaces::new(tcx, body, &move_data)

tests/mir-opt/basic_assignment.main.ElaborateDrops.diff

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,23 +35,53 @@
3535
StorageLive(_5);
3636
StorageLive(_6);
3737
_6 = move _4;
38+
- drop(_5) -> [return: bb1, unwind: bb2];
39+
+ goto -> bb1;
40+
}
41+
42+
bb1: {
3843
_5 = move _6;
44+
- drop(_6) -> [return: bb3, unwind: bb6];
45+
+ goto -> bb3;
46+
}
47+
48+
bb2 (cleanup): {
49+
_5 = move _6;
50+
- drop(_6) -> [return: bb6, unwind terminate(cleanup)];
51+
+ goto -> bb6;
52+
}
53+
54+
bb3: {
3955
StorageDead(_6);
4056
_0 = const ();
41-
- drop(_5) -> [return: bb1, unwind continue];
42-
+ drop(_5) -> [return: bb1, unwind: bb2];
57+
drop(_5) -> [return: bb4, unwind: bb7];
4358
}
4459

45-
bb1: {
60+
bb4: {
4661
StorageDead(_5);
62+
- drop(_4) -> [return: bb5, unwind continue];
63+
+ goto -> bb5;
64+
}
65+
66+
bb5: {
4767
StorageDead(_4);
4868
StorageDead(_2);
4969
StorageDead(_1);
5070
return;
51-
+ }
52-
+
53-
+ bb2 (cleanup): {
54-
+ resume;
71+
}
72+
73+
bb6 (cleanup): {
74+
- drop(_5) -> [return: bb7, unwind terminate(cleanup)];
75+
+ goto -> bb7;
76+
}
77+
78+
bb7 (cleanup): {
79+
- drop(_4) -> [return: bb8, unwind terminate(cleanup)];
80+
+ goto -> bb8;
81+
}
82+
83+
bb8 (cleanup): {
84+
resume;
5585
}
5686
}
5787

tests/mir-opt/box_conditional_drop_allocator.main.ElaborateDrops.diff

Lines changed: 57 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
_2 = HasDrop;
3232
StorageLive(_3);
3333
_3 = DropAllocator;
34-
+ _9 = const true;
35-
_1 = Box::<HasDrop, DropAllocator>::new_in(move _2, move _3) -> [return: bb1, unwind continue];
34+
_1 = Box::<HasDrop, DropAllocator>::new_in(move _2, move _3) -> [return: bb1, unwind: bb11];
3635
}
3736

3837
bb1: {
38+
+ _9 = const true;
3939
StorageDead(_3);
4040
StorageDead(_2);
4141
StorageLive(_4);
@@ -47,7 +47,7 @@
4747
StorageLive(_5);
4848
StorageLive(_6);
4949
_6 = move (*_1);
50-
_5 = std::mem::drop::<HasDrop>(move _6) -> [return: bb3, unwind: bb8];
50+
_5 = std::mem::drop::<HasDrop>(move _6) -> [return: bb3, unwind: bb9];
5151
}
5252

5353
bb3: {
@@ -75,7 +75,7 @@
7575
bb6: {
7676
StorageDead(_4);
7777
- drop(_1) -> [return: bb7, unwind continue];
78-
+ goto -> bb19;
78+
+ goto -> bb23;
7979
}
8080

8181
bb7: {
@@ -85,82 +85,102 @@
8585
}
8686

8787
bb8 (cleanup): {
88-
- drop(_1) -> [return: bb9, unwind terminate(cleanup)];
89-
+ goto -> bb25;
88+
- drop(_8) -> [return: bb10, unwind terminate(cleanup)];
89+
+ goto -> bb10;
9090
}
9191

9292
bb9 (cleanup): {
93+
- drop(_6) -> [return: bb10, unwind terminate(cleanup)];
94+
+ goto -> bb10;
95+
}
96+
97+
bb10 (cleanup): {
98+
- drop(_1) -> [return: bb13, unwind terminate(cleanup)];
99+
+ goto -> bb29;
100+
}
101+
102+
bb11 (cleanup): {
103+
- drop(_3) -> [return: bb12, unwind terminate(cleanup)];
104+
+ goto -> bb12;
105+
}
106+
107+
bb12 (cleanup): {
108+
- drop(_2) -> [return: bb13, unwind terminate(cleanup)];
109+
+ goto -> bb13;
110+
}
111+
112+
bb13 (cleanup): {
93113
resume;
94114
+ }
95115
+
96-
+ bb10: {
116+
+ bb14: {
97117
+ _9 = const false;
98118
+ goto -> bb7;
99119
+ }
100120
+
101-
+ bb11 (cleanup): {
102-
+ drop((_1.1: DropAllocator)) -> [return: bb9, unwind terminate(cleanup)];
121+
+ bb15 (cleanup): {
122+
+ drop((_1.1: DropAllocator)) -> [return: bb13, unwind terminate(cleanup)];
103123
+ }
104124
+
105-
+ bb12 (cleanup): {
106-
+ switchInt(copy _9) -> [0: bb9, otherwise: bb11];
125+
+ bb16 (cleanup): {
126+
+ switchInt(copy _9) -> [0: bb13, otherwise: bb15];
107127
+ }
108128
+
109-
+ bb13: {
110-
+ drop((_1.1: DropAllocator)) -> [return: bb10, unwind: bb9];
129+
+ bb17: {
130+
+ drop((_1.1: DropAllocator)) -> [return: bb14, unwind: bb13];
111131
+ }
112132
+
113-
+ bb14: {
114-
+ switchInt(copy _9) -> [0: bb10, otherwise: bb13];
133+
+ bb18: {
134+
+ switchInt(copy _9) -> [0: bb14, otherwise: bb17];
115135
+ }
116136
+
117-
+ bb15: {
137+
+ bb19: {
118138
+ _10 = &mut _1;
119-
+ _11 = <Box<HasDrop, DropAllocator> as Drop>::drop(move _10) -> [return: bb14, unwind: bb12];
139+
+ _11 = <Box<HasDrop, DropAllocator> as Drop>::drop(move _10) -> [return: bb18, unwind: bb16];
120140
+ }
121141
+
122-
+ bb16 (cleanup): {
142+
+ bb20 (cleanup): {
123143
+ _12 = &mut _1;
124-
+ _13 = <Box<HasDrop, DropAllocator> as Drop>::drop(move _12) -> [return: bb12, unwind terminate(cleanup)];
144+
+ _13 = <Box<HasDrop, DropAllocator> as Drop>::drop(move _12) -> [return: bb16, unwind terminate(cleanup)];
125145
+ }
126146
+
127-
+ bb17: {
128-
+ goto -> bb15;
147+
+ bb21: {
148+
+ goto -> bb19;
129149
+ }
130150
+
131-
+ bb18: {
151+
+ bb22: {
132152
+ _14 = copy ((_1.0: std::ptr::Unique<HasDrop>).0: std::ptr::NonNull<HasDrop>) as *const HasDrop (Transmute);
133-
+ goto -> bb17;
153+
+ goto -> bb21;
134154
+ }
135155
+
136-
+ bb19: {
137-
+ switchInt(copy _9) -> [0: bb14, otherwise: bb18];
156+
+ bb23: {
157+
+ switchInt(copy _9) -> [0: bb18, otherwise: bb22];
138158
+ }
139159
+
140-
+ bb20 (cleanup): {
141-
+ drop((_1.1: DropAllocator)) -> [return: bb9, unwind terminate(cleanup)];
160+
+ bb24 (cleanup): {
161+
+ drop((_1.1: DropAllocator)) -> [return: bb13, unwind terminate(cleanup)];
142162
+ }
143163
+
144-
+ bb21 (cleanup): {
145-
+ switchInt(copy _9) -> [0: bb9, otherwise: bb20];
164+
+ bb25 (cleanup): {
165+
+ switchInt(copy _9) -> [0: bb13, otherwise: bb24];
146166
+ }
147167
+
148-
+ bb22 (cleanup): {
168+
+ bb26 (cleanup): {
149169
+ _15 = &mut _1;
150-
+ _16 = <Box<HasDrop, DropAllocator> as Drop>::drop(move _15) -> [return: bb21, unwind terminate(cleanup)];
170+
+ _16 = <Box<HasDrop, DropAllocator> as Drop>::drop(move _15) -> [return: bb25, unwind terminate(cleanup)];
151171
+ }
152172
+
153-
+ bb23 (cleanup): {
154-
+ goto -> bb22;
173+
+ bb27 (cleanup): {
174+
+ goto -> bb26;
155175
+ }
156176
+
157-
+ bb24 (cleanup): {
177+
+ bb28 (cleanup): {
158178
+ _17 = copy ((_1.0: std::ptr::Unique<HasDrop>).0: std::ptr::NonNull<HasDrop>) as *const HasDrop (Transmute);
159-
+ goto -> bb23;
179+
+ goto -> bb27;
160180
+ }
161181
+
162-
+ bb25 (cleanup): {
163-
+ switchInt(copy _9) -> [0: bb21, otherwise: bb24];
182+
+ bb29 (cleanup): {
183+
+ switchInt(copy _9) -> [0: bb25, otherwise: bb28];
164184
}
165185
}
166186

tests/mir-opt/box_partial_move.maybe_move.ElaborateDrops.diff

Lines changed: 36 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -19,66 +19,76 @@
1919
+ _5 = const true;
2020
StorageLive(_3);
2121
_3 = copy _1;
22-
switchInt(move _3) -> [0: bb2, otherwise: bb1];
22+
switchInt(move _3) -> [0: bb3, otherwise: bb1];
2323
}
2424

2525
bb1: {
2626
StorageLive(_4);
2727
+ _5 = const false;
2828
_4 = move (*_2);
2929
_0 = Option::<String>::Some(move _4);
30-
StorageDead(_4);
31-
goto -> bb3;
30+
- drop(_4) -> [return: bb2, unwind: bb6];
31+
+ goto -> bb2;
3232
}
3333

3434
bb2: {
35-
_0 = Option::<String>::None;
36-
goto -> bb3;
35+
StorageDead(_4);
36+
goto -> bb4;
3737
}
3838

3939
bb3: {
40-
StorageDead(_3);
41-
- drop(_2) -> [return: bb4, unwind continue];
42-
+ goto -> bb12;
40+
_0 = Option::<String>::None;
41+
goto -> bb4;
4342
}
4443

4544
bb4: {
45+
StorageDead(_3);
46+
- drop(_2) -> [return: bb5, unwind continue];
47+
+ goto -> bb14;
48+
}
49+
50+
bb5: {
4651
return;
52+
}
53+
54+
bb6 (cleanup): {
55+
- drop(_2) -> [return: bb7, unwind terminate(cleanup)];
56+
+ goto -> bb7;
57+
}
58+
59+
bb7 (cleanup): {
60+
resume;
4761
+ }
4862
+
49-
+ bb5 (cleanup): {
50-
+ resume;
51-
+ }
52-
+
53-
+ bb6: {
54-
+ goto -> bb4;
63+
+ bb8: {
64+
+ goto -> bb5;
5565
+ }
5666
+
57-
+ bb7: {
67+
+ bb9: {
5868
+ _6 = &mut _2;
59-
+ _7 = <Box<String> as Drop>::drop(move _6) -> [return: bb6, unwind: bb5];
69+
+ _7 = <Box<String> as Drop>::drop(move _6) -> [return: bb8, unwind: bb7];
6070
+ }
6171
+
62-
+ bb8 (cleanup): {
72+
+ bb10 (cleanup): {
6373
+ _8 = &mut _2;
64-
+ _9 = <Box<String> as Drop>::drop(move _8) -> [return: bb5, unwind terminate(cleanup)];
74+
+ _9 = <Box<String> as Drop>::drop(move _8) -> [return: bb7, unwind terminate(cleanup)];
6575
+ }
6676
+
67-
+ bb9: {
68-
+ goto -> bb11;
77+
+ bb11: {
78+
+ goto -> bb13;
6979
+ }
7080
+
71-
+ bb10: {
72-
+ drop((*_10)) -> [return: bb7, unwind: bb8];
81+
+ bb12: {
82+
+ drop((*_10)) -> [return: bb9, unwind: bb10];
7383
+ }
7484
+
75-
+ bb11: {
76-
+ switchInt(copy _5) -> [0: bb7, otherwise: bb10];
85+
+ bb13: {
86+
+ switchInt(copy _5) -> [0: bb9, otherwise: bb12];
7787
+ }
7888
+
79-
+ bb12: {
89+
+ bb14: {
8090
+ _10 = copy ((_2.0: std::ptr::Unique<std::string::String>).0: std::ptr::NonNull<std::string::String>) as *const std::string::String (Transmute);
81-
+ goto -> bb9;
91+
+ goto -> bb11;
8292
}
8393
}
8494

0 commit comments

Comments
 (0)