Rollup merge of #133732 - nnethercote:fix-Z-dump-mir-dataflow, r=compiler-errors
Fix `-Zdump-mir-dataflow` r? `@cjgillot`
This commit is contained in:
commit
3586e4a326
7 changed files with 19 additions and 21 deletions
|
@ -15,7 +15,6 @@ pub enum ResultsHandle<'a, 'tcx, A>
|
||||||
where
|
where
|
||||||
A: Analysis<'tcx>,
|
A: Analysis<'tcx>,
|
||||||
{
|
{
|
||||||
Borrowed(&'a Results<'tcx, A>),
|
|
||||||
BorrowedMut(&'a mut Results<'tcx, A>),
|
BorrowedMut(&'a mut Results<'tcx, A>),
|
||||||
Owned(Results<'tcx, A>),
|
Owned(Results<'tcx, A>),
|
||||||
}
|
}
|
||||||
|
@ -28,7 +27,6 @@ where
|
||||||
|
|
||||||
fn deref(&self) -> &Results<'tcx, A> {
|
fn deref(&self) -> &Results<'tcx, A> {
|
||||||
match self {
|
match self {
|
||||||
ResultsHandle::Borrowed(borrowed) => borrowed,
|
|
||||||
ResultsHandle::BorrowedMut(borrowed) => borrowed,
|
ResultsHandle::BorrowedMut(borrowed) => borrowed,
|
||||||
ResultsHandle::Owned(owned) => owned,
|
ResultsHandle::Owned(owned) => owned,
|
||||||
}
|
}
|
||||||
|
@ -41,9 +39,6 @@ where
|
||||||
{
|
{
|
||||||
fn deref_mut(&mut self) -> &mut Results<'tcx, A> {
|
fn deref_mut(&mut self) -> &mut Results<'tcx, A> {
|
||||||
match self {
|
match self {
|
||||||
ResultsHandle::Borrowed(_borrowed) => {
|
|
||||||
panic!("tried to deref_mut a `ResultsHandle::Borrowed")
|
|
||||||
}
|
|
||||||
ResultsHandle::BorrowedMut(borrowed) => borrowed,
|
ResultsHandle::BorrowedMut(borrowed) => borrowed,
|
||||||
ResultsHandle::Owned(owned) => owned,
|
ResultsHandle::Owned(owned) => owned,
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ where
|
||||||
{
|
{
|
||||||
pub(crate) fn new(
|
pub(crate) fn new(
|
||||||
body: &'mir Body<'tcx>,
|
body: &'mir Body<'tcx>,
|
||||||
results: &'mir Results<'tcx, A>,
|
results: &'mir mut Results<'tcx, A>,
|
||||||
style: OutputStyle,
|
style: OutputStyle,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
let reachable = mir::traversal::reachable_as_bitset(body);
|
let reachable = mir::traversal::reachable_as_bitset(body);
|
||||||
|
|
|
@ -281,10 +281,10 @@ pub trait Analysis<'tcx> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let results = Results { analysis: self, entry_sets };
|
let mut results = Results { analysis: self, entry_sets };
|
||||||
|
|
||||||
if tcx.sess.opts.unstable_opts.dump_mir_dataflow {
|
if tcx.sess.opts.unstable_opts.dump_mir_dataflow {
|
||||||
let res = write_graphviz_results(tcx, body, &results, pass_name);
|
let res = write_graphviz_results(tcx, body, &mut results, pass_name);
|
||||||
if let Err(e) = res {
|
if let Err(e) = res {
|
||||||
error!("Failed to write graphviz dataflow results: {}", e);
|
error!("Failed to write graphviz dataflow results: {}", e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,18 +37,9 @@ impl<'tcx, A> Results<'tcx, A>
|
||||||
where
|
where
|
||||||
A: Analysis<'tcx>,
|
A: Analysis<'tcx>,
|
||||||
{
|
{
|
||||||
/// Creates a `ResultsCursor` that can inspect these `Results`. Immutably borrows the `Results`,
|
/// Creates a `ResultsCursor` that mutably borrows the `Results`, which is appropriate when the
|
||||||
/// which is appropriate when the `Results` is used outside the cursor.
|
/// `Results` is also used outside the cursor.
|
||||||
pub fn as_results_cursor<'mir>(
|
pub fn as_results_cursor<'mir>(
|
||||||
&'mir self,
|
|
||||||
body: &'mir mir::Body<'tcx>,
|
|
||||||
) -> ResultsCursor<'mir, 'tcx, A> {
|
|
||||||
ResultsCursor::new(body, ResultsHandle::Borrowed(self))
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Creates a `ResultsCursor` that can mutate these `Results`. Mutably borrows the `Results`,
|
|
||||||
/// which is appropriate when the `Results` is used outside the cursor.
|
|
||||||
pub fn as_results_cursor_mut<'mir>(
|
|
||||||
&'mir mut self,
|
&'mir mut self,
|
||||||
body: &'mir mir::Body<'tcx>,
|
body: &'mir mir::Body<'tcx>,
|
||||||
) -> ResultsCursor<'mir, 'tcx, A> {
|
) -> ResultsCursor<'mir, 'tcx, A> {
|
||||||
|
@ -95,7 +86,7 @@ where
|
||||||
pub(super) fn write_graphviz_results<'tcx, A>(
|
pub(super) fn write_graphviz_results<'tcx, A>(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
body: &mir::Body<'tcx>,
|
body: &mir::Body<'tcx>,
|
||||||
results: &Results<'tcx, A>,
|
results: &mut Results<'tcx, A>,
|
||||||
pass_name: Option<&'static str>,
|
pass_name: Option<&'static str>,
|
||||||
) -> std::io::Result<()>
|
) -> std::io::Result<()>
|
||||||
where
|
where
|
||||||
|
|
|
@ -680,7 +680,7 @@ fn locals_live_across_suspend_points<'tcx>(
|
||||||
let mut requires_storage_results =
|
let mut requires_storage_results =
|
||||||
MaybeRequiresStorage::new(borrowed_locals_results.into_results_cursor(body))
|
MaybeRequiresStorage::new(borrowed_locals_results.into_results_cursor(body))
|
||||||
.iterate_to_fixpoint(tcx, body, None);
|
.iterate_to_fixpoint(tcx, body, None);
|
||||||
let mut requires_storage_cursor = requires_storage_results.as_results_cursor_mut(body);
|
let mut requires_storage_cursor = requires_storage_results.as_results_cursor(body);
|
||||||
|
|
||||||
// Calculate the liveness of MIR locals ignoring borrows.
|
// Calculate the liveness of MIR locals ignoring borrows.
|
||||||
let mut liveness =
|
let mut liveness =
|
||||||
|
|
6
tests/mir-opt/dataflow.main.maybe_init.borrowck.dot
Normal file
6
tests/mir-opt/dataflow.main.maybe_init.borrowck.dot
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
digraph graph_for_def_id_0_3 {
|
||||||
|
graph[fontname="Courier, monospace"];
|
||||||
|
node[fontname="Courier, monospace"];
|
||||||
|
edge[fontname="Courier, monospace"];
|
||||||
|
bb_0[label=<<table border="1" cellborder="1" cellspacing="0" cellpadding="3" sides="rb"><tr><td colspan="3" sides="tl">bb0</td></tr><tr><td colspan="2" bgcolor="#a0a0a0" sides="tl">MIR</td><td bgcolor="#a0a0a0" sides="tl">STATE</td></tr><tr><td valign="bottom" sides="tl" align="right"></td><td valign="bottom" sides="tl" align="left">(on start)</td><td colspan="1" valign="bottom" sides="tl" align="left">{}</td></tr><tr><td valign="top" sides="tl" bgcolor="#f0f0f0" align="right">0</td><td valign="top" sides="tl" bgcolor="#f0f0f0" align="left">_0 = const ()</td><td valign="top" sides="tl" bgcolor="#f0f0f0" align="left"><font color="darkgreen">+_0</font></td></tr><tr><td valign="top" sides="tl" align="right">T</td><td valign="top" sides="tl" align="left">return</td><td valign="top" sides="tl" align="left"></td></tr><tr><td valign="bottom" sides="tl" bgcolor="#f0f0f0" align="right"></td><td valign="bottom" sides="tl" bgcolor="#f0f0f0" align="left">(on end)</td><td colspan="1" valign="bottom" sides="tl" bgcolor="#f0f0f0" align="left">{_0}</td></tr></table>>][shape="none"];
|
||||||
|
}
|
6
tests/mir-opt/dataflow.rs
Normal file
6
tests/mir-opt/dataflow.rs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
// skip-filecheck
|
||||||
|
// Test graphviz dataflow output
|
||||||
|
//@ compile-flags: -Z dump-mir=main -Z dump-mir-dataflow
|
||||||
|
|
||||||
|
// EMIT_MIR dataflow.main.maybe_init.borrowck.dot
|
||||||
|
fn main() {}
|
Loading…
Add table
Add a link
Reference in a new issue