mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-26 14:43:24 +00:00
Limit block count
This commit is contained in:
parent
5728834448
commit
7af964fecf
@ -115,7 +115,12 @@ use rustc_middle::mir::{
|
||||
};
|
||||
use rustc_middle::ty::{self, Ty, TyCtxt};
|
||||
|
||||
// Empirical measurements have resulted in some observations:
|
||||
// - Running on a body with a single block and 500 locals takes barely any time
|
||||
// - Running on a body with ~400 blocks and ~300 relevant locals takes "too long"
|
||||
// ...so we just limit both to somewhat reasonable-ish looking values.
|
||||
const MAX_LOCALS: usize = 500;
|
||||
const MAX_BLOCKS: usize = 250;
|
||||
|
||||
pub struct DestinationPropagation;
|
||||
|
||||
@ -160,6 +165,15 @@ impl<'tcx> MirPass<'tcx> for DestinationPropagation {
|
||||
);
|
||||
return;
|
||||
}
|
||||
if body.basic_blocks().len() > MAX_BLOCKS {
|
||||
warn!(
|
||||
"too many blocks in {:?} ({}, max is {}), not optimizing",
|
||||
source.def_id(),
|
||||
body.basic_blocks().len(),
|
||||
MAX_BLOCKS
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
let mut conflicts = Conflicts::build(tcx, body, source, &relevant_locals);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user