Limit number of basic blocks and tracked places to 100 for now

This commit is contained in:
Jannis Christopher Köhl 2022-10-27 16:50:39 +02:00
parent b478fcf270
commit 72196ee666

View File

@ -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;
}