summaryrefslogtreecommitdiff
path: root/compiler/rustc_mir_dataflow
diff options
context:
space:
mode:
authorYuki Okushi <jtitor@2k36.org>2023-04-05 20:47:22 +0900
committerGitHub <noreply@github.com>2023-04-05 20:47:22 +0900
commit4e0662c8a7c61a4346536bb06aefb4fe2a455ac2 (patch)
treef1994847eb2531e7e3da65520ba2384afb8bc2d1 /compiler/rustc_mir_dataflow
parent630f2fc850006394061256bdc66b6ee646f73a54 (diff)
parent47ae42ee101c36fe18a5fe15e6cb501c8992fe7a (diff)
downloadrust-4e0662c8a7c61a4346536bb06aefb4fe2a455ac2.tar.gz
Rollup merge of #109847 - clubby789:graphviz-reachable, r=oli-obk
Only create graphviz nodes for reachable MIR bb's Fixes #109832
Diffstat (limited to 'compiler/rustc_mir_dataflow')
-rw-r--r--compiler/rustc_mir_dataflow/src/framework/graphviz.rs12
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> {