File tree Expand file tree Collapse file tree 3 files changed +17
-16
lines changed
compiler/rustc_mir/src/transform Expand file tree Collapse file tree 3 files changed +17
-16
lines changed Original file line number Diff line number Diff line change @@ -14,14 +14,9 @@ impl<'tcx> MirPass<'tcx> for MultipleReturnTerminators {
1414 return ;
1515 }
1616
17- if !tcx. consider_optimizing ( || {
18- format ! ( "MultipleReturnTerminators {:?} " , body. source. def_id( ) )
19- } ) {
20- return ;
21- }
22-
2317 // find basic blocks with no statement and a return terminator
2418 let mut bbs_simple_returns = BitSet :: new_empty ( body. basic_blocks ( ) . len ( ) ) ;
19+ let def_id = body. source . def_id ( ) ;
2520 let bbs = body. basic_blocks_mut ( ) ;
2621 for idx in bbs. indices ( ) {
2722 if bbs[ idx] . statements . is_empty ( )
@@ -32,6 +27,10 @@ impl<'tcx> MirPass<'tcx> for MultipleReturnTerminators {
3227 }
3328
3429 for bb in bbs {
30+ if !tcx. consider_optimizing ( || format ! ( "MultipleReturnTerminators {:?} " , def_id) ) {
31+ break ;
32+ }
33+
3534 if let TerminatorKind :: Goto { target } = bb. terminator ( ) . kind {
3635 if bbs_simple_returns. contains ( target) {
3736 bb. terminator_mut ( ) . kind = TerminatorKind :: Return ;
Original file line number Diff line number Diff line change @@ -11,10 +11,6 @@ pub struct RemoveUnneededDrops;
1111
1212impl < ' tcx > MirPass < ' tcx > for RemoveUnneededDrops {
1313 fn run_pass ( & self , tcx : TyCtxt < ' tcx > , body : & mut Body < ' tcx > ) {
14- if !tcx. consider_optimizing ( || format ! ( "RemoveUnneededDrops {:?} " , body. source. def_id( ) ) ) {
15- return ;
16- }
17-
1814 trace ! ( "Running RemoveUnneededDrops on {:?}" , body. source) ;
1915 let mut opt_finder = RemoveUnneededDropsOptimizationFinder {
2016 tcx,
@@ -25,6 +21,12 @@ impl<'tcx> MirPass<'tcx> for RemoveUnneededDrops {
2521 opt_finder. visit_body ( body) ;
2622 let should_simplify = !opt_finder. optimizations . is_empty ( ) ;
2723 for ( loc, target) in opt_finder. optimizations {
24+ if !tcx
25+ . consider_optimizing ( || format ! ( "RemoveUnneededDrops {:?} " , body. source. def_id( ) ) )
26+ {
27+ break ;
28+ }
29+
2830 let terminator = body. basic_blocks_mut ( ) [ loc. block ] . terminator_mut ( ) ;
2931 debug ! ( "SUCCESS: replacing `drop` with goto({:?})" , target) ;
3032 terminator. kind = TerminatorKind :: Goto { target } ;
Original file line number Diff line number Diff line change @@ -18,12 +18,6 @@ impl MirPass<'_> for UnreachablePropagation {
1818 return ;
1919 }
2020
21- if !tcx
22- . consider_optimizing ( || format ! ( "UnreachablePropagation {:?} " , body. source. def_id( ) ) )
23- {
24- return ;
25- }
26-
2721 let mut unreachable_blocks = FxHashSet :: default ( ) ;
2822 let mut replacements = FxHashMap :: default ( ) ;
2923
@@ -56,6 +50,12 @@ impl MirPass<'_> for UnreachablePropagation {
5650
5751 let replaced = !replacements. is_empty ( ) ;
5852 for ( bb, terminator_kind) in replacements {
53+ if !tcx. consider_optimizing ( || {
54+ format ! ( "UnreachablePropagation {:?} " , body. source. def_id( ) )
55+ } ) {
56+ break ;
57+ }
58+
5959 body. basic_blocks_mut ( ) [ bb] . terminator_mut ( ) . kind = terminator_kind;
6060 }
6161
You can’t perform that action at this time.
0 commit comments