@@ -21,23 +21,28 @@ impl MirPass for Deaggregator {
2121 tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
2222 source : MirSource ,
2323 mir : & mut Mir < ' tcx > ) {
24- let node_path = tcx. item_path_str ( source. def_id ) ;
25- debug ! ( "running on: {:?}" , node_path) ;
26- // we only run when mir_opt_level > 2
27- if tcx. sess . opts . debugging_opts . mir_opt_level <= 2 {
28- return ;
29- }
30-
3124 // Don't run on constant MIR, because trans might not be able to
3225 // evaluate the modified MIR.
3326 // FIXME(eddyb) Remove check after miri is merged.
3427 let id = tcx. hir . as_local_node_id ( source. def_id ) . unwrap ( ) ;
3528 match ( tcx. hir . body_owner_kind ( id) , source. promoted ) {
36- ( hir:: BodyOwnerKind :: Fn , None ) => { } ,
37- _ => return
29+ ( _, Some ( _) ) |
30+ ( hir:: BodyOwnerKind :: Const , _) |
31+ ( hir:: BodyOwnerKind :: Static ( _) , _) => return ,
32+
33+ ( hir:: BodyOwnerKind :: Fn , _) => {
34+ if tcx. is_const_fn ( source. def_id ) {
35+ // Don't run on const functions, as, again, trans might not be able to evaluate
36+ // the optimized IR.
37+ return
38+ }
39+ }
40+ }
41+
42+ // We only run when the MIR optimization level is > 2.
43+ if tcx. sess . opts . debugging_opts . mir_opt_level <= 2 {
44+ return ;
3845 }
39- // In fact, we might not want to trigger in other cases.
40- // Ex: when we could use SROA. See issue #35259
4146
4247 for bb in mir. basic_blocks_mut ( ) {
4348 let mut curr: usize = 0 ;
0 commit comments