Skip to content

Commit ea23585

Browse files
committed
Disable limits if mir-opt-level >= 4
1 parent d66a00a commit ea23585

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

compiler/rustc_mir_transform/src/dataflow_const_prop.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use rustc_span::DUMMY_SP;
1414
use crate::MirPass;
1515

1616
// These constants are somewhat random guesses and have not been optimized.
17+
// If `tcx.sess.mir_opt_level() >= 4`, we ignore the limits (this can become very expensive).
1718
const BLOCK_LIMIT: usize = 100;
1819
const PLACE_LIMIT: usize = 100;
1920

@@ -26,7 +27,7 @@ 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>) {
29-
if body.basic_blocks.len() > BLOCK_LIMIT {
30+
if tcx.sess.mir_opt_level() < 4 && body.basic_blocks.len() > BLOCK_LIMIT {
3031
debug!("aborted dataflow const prop due too many basic blocks");
3132
return;
3233
}
@@ -42,7 +43,7 @@ impl<'tcx> MirPass<'tcx> for DataflowConstProp {
4243
// `O(num_nodes * tracked_places * n)` in terms of time complexity. Since the number of
4344
// map nodes is strongly correlated to the number of tracked places, this becomes more or
4445
// less `O(n)` if we place a constant limit on the number of tracked places.
45-
if map.tracked_places() > PLACE_LIMIT {
46+
if tcx.sess.mir_opt_level() < 4 && map.tracked_places() > PLACE_LIMIT {
4647
debug!("aborted dataflow const prop due to too many tracked places");
4748
return;
4849
}

0 commit comments

Comments
 (0)