diff --git a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs index acb0f7b95abc..001b83ccda23 100644 --- a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs +++ b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs @@ -15,7 +15,8 @@ use rustc_span::DUMMY_SP; use crate::MirPass; -const TRACKING_LIMIT: usize = 1000; +const BLOCK_LIMIT: usize = 100; +const PLACE_LIMIT: usize = 100; pub struct DataflowConstProp; @@ -26,6 +27,11 @@ impl<'tcx> MirPass<'tcx> for DataflowConstProp { #[instrument(skip_all level = "debug")] fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { + if body.basic_blocks.len() > BLOCK_LIMIT { + debug!("aborted dataflow const prop due too many basic blocks"); + return; + } + // Decide which places to track during the analysis. let map = Map::from_filter(tcx, body, Ty::is_scalar); @@ -37,7 +43,7 @@ impl<'tcx> MirPass<'tcx> for DataflowConstProp { // `O(num_nodes * tracked_places * n)` in terms of time complexity. Since the number of // map nodes is strongly correlated to the number of tracked places, this becomes more or // less `O(n)` if we place a constant limit on the number of tracked places. - if map.tracked_places() > TRACKING_LIMIT { + if map.tracked_places() > PLACE_LIMIT { debug!("aborted dataflow const prop due to too many tracked places"); return; }