File tree 1 file changed +14
-0
lines changed
src/librustc_mir/transform 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::{
115
115
} ;
116
116
use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
117
117
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.
118
122
const MAX_LOCALS : usize = 500 ;
123
+ const MAX_BLOCKS : usize = 250 ;
119
124
120
125
pub struct DestinationPropagation ;
121
126
@@ -160,6 +165,15 @@ impl<'tcx> MirPass<'tcx> for DestinationPropagation {
160
165
) ;
161
166
return ;
162
167
}
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
+ }
163
177
164
178
let mut conflicts = Conflicts :: build ( tcx, body, source, & relevant_locals) ;
165
179
You can’t perform that action at this time.
0 commit comments