Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 72196ee

Browse files
committed
Limit number of basic blocks and tracked places to 100 for now
1 parent b478fcf commit 72196ee

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

compiler/rustc_mir_transform/src/dataflow_const_prop.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ use rustc_span::DUMMY_SP;
1515

1616
use crate::MirPass;
1717

18-
const TRACKING_LIMIT: usize = 1000;
18+
const BLOCK_LIMIT: usize = 100;
19+
const PLACE_LIMIT: usize = 100;
1920

2021
pub 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
}

0 commit comments

Comments
 (0)