@@ -21,23 +21,28 @@ impl MirPass for Deaggregator {
21
21
tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
22
22
source : MirSource ,
23
23
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
-
31
24
// Don't run on constant MIR, because trans might not be able to
32
25
// evaluate the modified MIR.
33
26
// FIXME(eddyb) Remove check after miri is merged.
34
27
let id = tcx. hir . as_local_node_id ( source. def_id ) . unwrap ( ) ;
35
28
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 ;
38
45
}
39
- // In fact, we might not want to trigger in other cases.
40
- // Ex: when we could use SROA. See issue #35259
41
46
42
47
for bb in mir. basic_blocks_mut ( ) {
43
48
let mut curr: usize = 0 ;
0 commit comments