@@ -21,23 +21,23 @@ 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
+ }
38
40
}
39
- // In fact, we might not want to trigger in other cases.
40
- // Ex: when we could use SROA. See issue #35259
41
41
42
42
for bb in mir. basic_blocks_mut ( ) {
43
43
let mut curr: usize = 0 ;
@@ -107,6 +107,7 @@ impl MirPass for Deaggregator {
107
107
}
108
108
}
109
109
110
+ // FIXME(eddyb) clean up and support all aggregates.
110
111
fn get_aggregate_statement_index < ' a , ' tcx , ' b > ( start : usize ,
111
112
statements : & Vec < Statement < ' tcx > > )
112
113
-> Option < usize > {
0 commit comments