Limit number of basic blocks and tracked places to 100 for now
This commit is contained in:
parent
b478fcf270
commit
72196ee666
@ -15,7 +15,8 @@ use rustc_span::DUMMY_SP;
|
|||||||
|
|
||||||
use crate::MirPass;
|
use crate::MirPass;
|
||||||
|
|
||||||
const TRACKING_LIMIT: usize = 1000;
|
const BLOCK_LIMIT: usize = 100;
|
||||||
|
const PLACE_LIMIT: usize = 100;
|
||||||
|
|
||||||
pub struct DataflowConstProp;
|
pub struct DataflowConstProp;
|
||||||
|
|
||||||
@ -26,6 +27,11 @@ impl<'tcx> MirPass<'tcx> for DataflowConstProp {
|
|||||||
|
|
||||||
#[instrument(skip_all level = "debug")]
|
#[instrument(skip_all level = "debug")]
|
||||||
fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) {
|
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.
|
// Decide which places to track during the analysis.
|
||||||
let map = Map::from_filter(tcx, body, Ty::is_scalar);
|
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
|
// `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
|
// 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.
|
// 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");
|
debug!("aborted dataflow const prop due to too many tracked places");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user