about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJannis Christopher Köhl <mail@koehl.dev>2022-10-27 16:50:39 +0200
committerJannis Christopher Köhl <mail@koehl.dev>2022-11-07 10:35:26 +0100
commit72196ee6661a38cb640d66c2a8d9941f9d6c6bf4 (patch)
tree68f4668d62fcad8b946e4d5c60ae135296648bf3
parentb478fcf2705dee1ee0a03461c0dd3856760c42eb (diff)
downloadrust-72196ee6661a38cb640d66c2a8d9941f9d6c6bf4.tar.gz
rust-72196ee6661a38cb640d66c2a8d9941f9d6c6bf4.zip
Limit number of basic blocks and tracked places to 100 for now
-rw-r--r--compiler/rustc_mir_transform/src/dataflow_const_prop.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/compiler/rustc_mir_transform/src/dataflow_const_prop.rs b/compiler/rustc_mir_transform/src/dataflow_const_prop.rs
index acb0f7b95ab..001b83ccda2 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;
         }