File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
compiler/rustc_mir/src/transform Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -115,7 +115,12 @@ use rustc_middle::mir::{
115115} ;
116116use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
117117
118+ // Empirical measurements have resulted in some observations:
119+ // - Running on a body with a single block and 500 locals takes barely any time
120+ // - Running on a body with ~400 blocks and ~300 relevant locals takes "too long"
121+ // ...so we just limit both to somewhat reasonable-ish looking values.
118122const MAX_LOCALS : usize = 500 ;
123+ const MAX_BLOCKS : usize = 250 ;
119124
120125pub struct DestinationPropagation ;
121126
@@ -160,6 +165,15 @@ impl<'tcx> MirPass<'tcx> for DestinationPropagation {
160165 ) ;
161166 return ;
162167 }
168+ if body. basic_blocks ( ) . len ( ) > MAX_BLOCKS {
169+ warn ! (
170+ "too many blocks in {:?} ({}, max is {}), not optimizing" ,
171+ source. def_id( ) ,
172+ body. basic_blocks( ) . len( ) ,
173+ MAX_BLOCKS
174+ ) ;
175+ return ;
176+ }
163177
164178 let mut conflicts = Conflicts :: build ( tcx, body, source, & relevant_locals) ;
165179
You can’t perform that action at this time.
0 commit comments