File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
compiler/rustc_mir_transform/src Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,8 @@ use rustc_span::DUMMY_SP;
1515
1616use crate :: MirPass ;
1717
18- const TRACKING_LIMIT : usize = 1000 ;
18+ const BLOCK_LIMIT : usize = 100 ;
19+ const PLACE_LIMIT : usize = 100 ;
1920
2021pub struct DataflowConstProp ;
2122
@@ -26,6 +27,11 @@ impl<'tcx> MirPass<'tcx> for DataflowConstProp {
2627
2728 #[ instrument( skip_all level = "debug" ) ]
2829 fn run_pass ( & self , tcx : TyCtxt < ' tcx > , body : & mut Body < ' tcx > ) {
30+ if body. basic_blocks . len ( ) > BLOCK_LIMIT {
31+ debug ! ( "aborted dataflow const prop due too many basic blocks" ) ;
32+ return ;
33+ }
34+
2935 // Decide which places to track during the analysis.
3036 let map = Map :: from_filter ( tcx, body, Ty :: is_scalar) ;
3137
@@ -37,7 +43,7 @@ impl<'tcx> MirPass<'tcx> for DataflowConstProp {
3743 // `O(num_nodes * tracked_places * n)` in terms of time complexity. Since the number of
3844 // map nodes is strongly correlated to the number of tracked places, this becomes more or
3945 // less `O(n)` if we place a constant limit on the number of tracked places.
40- if map. tracked_places ( ) > TRACKING_LIMIT {
46+ if map. tracked_places ( ) > PLACE_LIMIT {
4147 debug ! ( "aborted dataflow const prop due to too many tracked places" ) ;
4248 return ;
4349 }
You can’t perform that action at this time.
0 commit comments