Skip to content

Rollup of 6 pull requests #109966

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Apr 5, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Only create graphviz nodes for reachable MIR bb's
  • Loading branch information
clubby789 committed Apr 1, 2023
commit 47ae42ee101c36fe18a5fe15e6cb501c8992fe7a
12 changes: 10 additions & 2 deletions compiler/rustc_mir_dataflow/src/framework/graphviz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -34,14 +35,16 @@ where
body: &'a Body<'tcx>,
results: &'a Results<'tcx, A>,
style: OutputStyle,
reachable: BitSet<BasicBlock>,
}

impl<'a, 'tcx, A> Formatter<'a, 'tcx, A>
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 }
}
}

Expand Down Expand Up @@ -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> {
Expand Down