diff options
| author | clubby789 <jamie@hill-daniel.co.uk> | 2023-04-01 23:14:18 +0100 |
|---|---|---|
| committer | clubby789 <jamie@hill-daniel.co.uk> | 2023-04-01 23:14:18 +0100 |
| commit | 47ae42ee101c36fe18a5fe15e6cb501c8992fe7a (patch) | |
| tree | 63fc6738ab6064bd8c8569af00f8d714ab84f95b /compiler/rustc_mir_dataflow/src/framework | |
| parent | b9535c0b7d64290b27c4a116262402cd12f77833 (diff) | |
| download | rust-47ae42ee101c36fe18a5fe15e6cb501c8992fe7a.tar.gz rust-47ae42ee101c36fe18a5fe15e6cb501c8992fe7a.zip | |
Only create graphviz nodes for reachable MIR bb's
Diffstat (limited to 'compiler/rustc_mir_dataflow/src/framework')
| -rw-r--r-- | compiler/rustc_mir_dataflow/src/framework/graphviz.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/compiler/rustc_mir_dataflow/src/framework/graphviz.rs b/compiler/rustc_mir_dataflow/src/framework/graphviz.rs index 96c42894b69..c188105eae8 100644 --- a/compiler/rustc_mir_dataflow/src/framework/graphviz.rs +++ b/compiler/rustc_mir_dataflow/src/framework/graphviz.rs @@ -6,6 +6,7 @@ use std::{io, ops, str}; use regex::Regex; use rustc_graphviz as dot; +use rustc_index::bit_set::BitSet; use rustc_middle::mir::graphviz_safe_def_name; use rustc_middle::mir::{self, BasicBlock, Body, Location}; @@ -34,6 +35,7 @@ where body: &'a Body<'tcx>, results: &'a Results<'tcx, A>, style: OutputStyle, + reachable: BitSet<BasicBlock>, } impl<'a, 'tcx, A> Formatter<'a, 'tcx, A> @@ -41,7 +43,8 @@ where A: Analysis<'tcx>, { pub fn new(body: &'a Body<'tcx>, results: &'a Results<'tcx, A>, style: OutputStyle) -> Self { - Formatter { body, results, style } + let reachable = mir::traversal::reachable_as_bitset(body); + Formatter { body, results, style, reachable } } } @@ -108,7 +111,12 @@ where type Edge = CfgEdge; fn nodes(&self) -> dot::Nodes<'_, Self::Node> { - self.body.basic_blocks.indices().collect::<Vec<_>>().into() + self.body + .basic_blocks + .indices() + .filter(|&idx| self.reachable.contains(idx)) + .collect::<Vec<_>>() + .into() } fn edges(&self) -> dot::Edges<'_, Self::Edge> { |
