diff options
| author | Jonas Schievink <jonasschievink@gmail.com> | 2020-06-24 22:55:12 +0200 |
|---|---|---|
| committer | Jonas Schievink <jonasschievink@gmail.com> | 2020-09-18 21:23:01 +0200 |
| commit | 7af964fecf77696e523020a430fd4a0d0d4bc190 (patch) | |
| tree | 757354e71d4687d9a3170f7d1f7f78a7d76978d0 | |
| parent | 572883444899ea0aecd5cd6cdf3466255dd4c7e0 (diff) | |
| download | rust-7af964fecf77696e523020a430fd4a0d0d4bc190.tar.gz rust-7af964fecf77696e523020a430fd4a0d0d4bc190.zip | |
Limit block count
| -rw-r--r-- | compiler/rustc_mir/src/transform/dest_prop.rs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/compiler/rustc_mir/src/transform/dest_prop.rs b/compiler/rustc_mir/src/transform/dest_prop.rs index f9071ab9d80..8080f4a0d65 100644 --- a/compiler/rustc_mir/src/transform/dest_prop.rs +++ b/compiler/rustc_mir/src/transform/dest_prop.rs @@ -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); |
