Rollup merge of #76724 - ecstatic-morse:dataflow-pass-names, r=lcnr
Allow a unique name to be assigned to dataflow graphviz output Previously, if the same analysis were invoked multiple times in a single compilation session, the graphviz output for later runs would overwrite that of previous runs. Allow callers to add a unique identifier to each run so this can be avoided.
This commit is contained in:
commit
d766c239bd
6 changed files with 34 additions and 4 deletions
|
@ -205,6 +205,7 @@ fn do_mir_borrowck<'a, 'tcx>(
|
||||||
|
|
||||||
let mut flow_inits = MaybeInitializedPlaces::new(tcx, &body, &mdpe)
|
let mut flow_inits = MaybeInitializedPlaces::new(tcx, &body, &mdpe)
|
||||||
.into_engine(tcx, &body, def.did.to_def_id())
|
.into_engine(tcx, &body, def.did.to_def_id())
|
||||||
|
.pass_name("borrowck")
|
||||||
.iterate_to_fixpoint()
|
.iterate_to_fixpoint()
|
||||||
.into_results_cursor(&body);
|
.into_results_cursor(&body);
|
||||||
|
|
||||||
|
@ -264,12 +265,15 @@ fn do_mir_borrowck<'a, 'tcx>(
|
||||||
|
|
||||||
let flow_borrows = Borrows::new(tcx, &body, regioncx.clone(), &borrow_set)
|
let flow_borrows = Borrows::new(tcx, &body, regioncx.clone(), &borrow_set)
|
||||||
.into_engine(tcx, &body, def.did.to_def_id())
|
.into_engine(tcx, &body, def.did.to_def_id())
|
||||||
|
.pass_name("borrowck")
|
||||||
.iterate_to_fixpoint();
|
.iterate_to_fixpoint();
|
||||||
let flow_uninits = MaybeUninitializedPlaces::new(tcx, &body, &mdpe)
|
let flow_uninits = MaybeUninitializedPlaces::new(tcx, &body, &mdpe)
|
||||||
.into_engine(tcx, &body, def.did.to_def_id())
|
.into_engine(tcx, &body, def.did.to_def_id())
|
||||||
|
.pass_name("borrowck")
|
||||||
.iterate_to_fixpoint();
|
.iterate_to_fixpoint();
|
||||||
let flow_ever_inits = EverInitializedPlaces::new(tcx, &body, &mdpe)
|
let flow_ever_inits = EverInitializedPlaces::new(tcx, &body, &mdpe)
|
||||||
.into_engine(tcx, &body, def.did.to_def_id())
|
.into_engine(tcx, &body, def.did.to_def_id())
|
||||||
|
.pass_name("borrowck")
|
||||||
.iterate_to_fixpoint();
|
.iterate_to_fixpoint();
|
||||||
|
|
||||||
let movable_generator = match tcx.hir().get(id) {
|
let movable_generator = match tcx.hir().get(id) {
|
||||||
|
|
|
@ -84,6 +84,7 @@ where
|
||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
dead_unwinds: Option<&'a BitSet<BasicBlock>>,
|
dead_unwinds: Option<&'a BitSet<BasicBlock>>,
|
||||||
entry_sets: IndexVec<BasicBlock, A::Domain>,
|
entry_sets: IndexVec<BasicBlock, A::Domain>,
|
||||||
|
pass_name: Option<&'static str>,
|
||||||
analysis: A,
|
analysis: A,
|
||||||
|
|
||||||
/// Cached, cumulative transfer functions for each block.
|
/// Cached, cumulative transfer functions for each block.
|
||||||
|
@ -174,6 +175,7 @@ where
|
||||||
body,
|
body,
|
||||||
def_id,
|
def_id,
|
||||||
dead_unwinds: None,
|
dead_unwinds: None,
|
||||||
|
pass_name: None,
|
||||||
entry_sets,
|
entry_sets,
|
||||||
apply_trans_for_block,
|
apply_trans_for_block,
|
||||||
}
|
}
|
||||||
|
@ -189,6 +191,15 @@ where
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Adds an identifier to the graphviz output for this particular run of a dataflow analysis.
|
||||||
|
///
|
||||||
|
/// Some analyses are run multiple times in the compilation pipeline. Give them a `pass_name`
|
||||||
|
/// to differentiate them. Otherwise, only the results for the latest run will be saved.
|
||||||
|
pub fn pass_name(mut self, name: &'static str) -> Self {
|
||||||
|
self.pass_name = Some(name);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Computes the fixpoint for this dataflow problem and returns it.
|
/// Computes the fixpoint for this dataflow problem and returns it.
|
||||||
pub fn iterate_to_fixpoint(self) -> Results<'tcx, A>
|
pub fn iterate_to_fixpoint(self) -> Results<'tcx, A>
|
||||||
where
|
where
|
||||||
|
@ -202,6 +213,7 @@ where
|
||||||
mut entry_sets,
|
mut entry_sets,
|
||||||
tcx,
|
tcx,
|
||||||
apply_trans_for_block,
|
apply_trans_for_block,
|
||||||
|
pass_name,
|
||||||
..
|
..
|
||||||
} = self;
|
} = self;
|
||||||
|
|
||||||
|
@ -249,7 +261,7 @@ where
|
||||||
|
|
||||||
let results = Results { analysis, entry_sets };
|
let results = Results { analysis, entry_sets };
|
||||||
|
|
||||||
let res = write_graphviz_results(tcx, def_id, &body, &results);
|
let res = write_graphviz_results(tcx, def_id, &body, &results, pass_name);
|
||||||
if let Err(e) = res {
|
if let Err(e) = res {
|
||||||
warn!("Failed to write graphviz dataflow results: {}", e);
|
warn!("Failed to write graphviz dataflow results: {}", e);
|
||||||
}
|
}
|
||||||
|
@ -267,6 +279,7 @@ fn write_graphviz_results<A>(
|
||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
body: &mir::Body<'tcx>,
|
body: &mir::Body<'tcx>,
|
||||||
results: &Results<'tcx, A>,
|
results: &Results<'tcx, A>,
|
||||||
|
pass_name: Option<&'static str>,
|
||||||
) -> std::io::Result<()>
|
) -> std::io::Result<()>
|
||||||
where
|
where
|
||||||
A: Analysis<'tcx>,
|
A: Analysis<'tcx>,
|
||||||
|
@ -285,12 +298,17 @@ where
|
||||||
None if tcx.sess.opts.debugging_opts.dump_mir_dataflow
|
None if tcx.sess.opts.debugging_opts.dump_mir_dataflow
|
||||||
&& dump_enabled(tcx, A::NAME, def_id) =>
|
&& dump_enabled(tcx, A::NAME, def_id) =>
|
||||||
{
|
{
|
||||||
|
// FIXME: Use some variant of `pretty::dump_path` for this
|
||||||
let mut path = PathBuf::from(&tcx.sess.opts.debugging_opts.dump_mir_dir);
|
let mut path = PathBuf::from(&tcx.sess.opts.debugging_opts.dump_mir_dir);
|
||||||
|
|
||||||
|
let crate_name = tcx.crate_name(def_id.krate);
|
||||||
let item_name = ty::print::with_forced_impl_filename_line(|| {
|
let item_name = ty::print::with_forced_impl_filename_line(|| {
|
||||||
tcx.def_path(def_id).to_filename_friendly_no_crate()
|
tcx.def_path(def_id).to_filename_friendly_no_crate()
|
||||||
});
|
});
|
||||||
path.push(format!("rustc.{}.{}.dot", item_name, A::NAME));
|
|
||||||
|
let pass_name = pass_name.map(|s| format!(".{}", s)).unwrap_or_default();
|
||||||
|
|
||||||
|
path.push(format!("{}.{}.{}{}.dot", crate_name, item_name, A::NAME, pass_name));
|
||||||
path
|
path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ impl Qualifs<'mir, 'tcx> {
|
||||||
MaybeMutBorrowedLocals::mut_borrows_only(tcx, &body, param_env)
|
MaybeMutBorrowedLocals::mut_borrows_only(tcx, &body, param_env)
|
||||||
.unsound_ignore_borrow_on_drop()
|
.unsound_ignore_borrow_on_drop()
|
||||||
.into_engine(tcx, &body, def_id.to_def_id())
|
.into_engine(tcx, &body, def_id.to_def_id())
|
||||||
|
.pass_name("const_qualification")
|
||||||
.iterate_to_fixpoint()
|
.iterate_to_fixpoint()
|
||||||
.into_results_cursor(&body)
|
.into_results_cursor(&body)
|
||||||
});
|
});
|
||||||
|
|
|
@ -44,6 +44,7 @@ impl<'tcx> MirPass<'tcx> for ElaborateDrops {
|
||||||
let inits = MaybeInitializedPlaces::new(tcx, body, &env)
|
let inits = MaybeInitializedPlaces::new(tcx, body, &env)
|
||||||
.into_engine(tcx, body, def_id)
|
.into_engine(tcx, body, def_id)
|
||||||
.dead_unwinds(&dead_unwinds)
|
.dead_unwinds(&dead_unwinds)
|
||||||
|
.pass_name("elaborate_drops")
|
||||||
.iterate_to_fixpoint()
|
.iterate_to_fixpoint()
|
||||||
.into_results_cursor(body);
|
.into_results_cursor(body);
|
||||||
|
|
||||||
|
@ -51,6 +52,7 @@ impl<'tcx> MirPass<'tcx> for ElaborateDrops {
|
||||||
.mark_inactive_variants_as_uninit()
|
.mark_inactive_variants_as_uninit()
|
||||||
.into_engine(tcx, body, def_id)
|
.into_engine(tcx, body, def_id)
|
||||||
.dead_unwinds(&dead_unwinds)
|
.dead_unwinds(&dead_unwinds)
|
||||||
|
.pass_name("elaborate_drops")
|
||||||
.iterate_to_fixpoint()
|
.iterate_to_fixpoint()
|
||||||
.into_results_cursor(body);
|
.into_results_cursor(body);
|
||||||
|
|
||||||
|
@ -83,6 +85,7 @@ fn find_dead_unwinds<'tcx>(
|
||||||
let mut dead_unwinds = BitSet::new_empty(body.basic_blocks().len());
|
let mut dead_unwinds = BitSet::new_empty(body.basic_blocks().len());
|
||||||
let mut flow_inits = MaybeInitializedPlaces::new(tcx, body, &env)
|
let mut flow_inits = MaybeInitializedPlaces::new(tcx, body, &env)
|
||||||
.into_engine(tcx, body, def_id)
|
.into_engine(tcx, body, def_id)
|
||||||
|
.pass_name("find_dead_unwinds")
|
||||||
.iterate_to_fixpoint()
|
.iterate_to_fixpoint()
|
||||||
.into_results_cursor(body);
|
.into_results_cursor(body);
|
||||||
for (bb, bb_data) in body.basic_blocks().iter_enumerated() {
|
for (bb, bb_data) in body.basic_blocks().iter_enumerated() {
|
||||||
|
|
|
@ -467,8 +467,10 @@ fn locals_live_across_suspend_points(
|
||||||
|
|
||||||
// Calculate the MIR locals which have been previously
|
// Calculate the MIR locals which have been previously
|
||||||
// borrowed (even if they are still active).
|
// borrowed (even if they are still active).
|
||||||
let borrowed_locals_results =
|
let borrowed_locals_results = MaybeBorrowedLocals::all_borrows()
|
||||||
MaybeBorrowedLocals::all_borrows().into_engine(tcx, body_ref, def_id).iterate_to_fixpoint();
|
.into_engine(tcx, body_ref, def_id)
|
||||||
|
.pass_name("generator")
|
||||||
|
.iterate_to_fixpoint();
|
||||||
|
|
||||||
let mut borrowed_locals_cursor =
|
let mut borrowed_locals_cursor =
|
||||||
dataflow::ResultsCursor::new(body_ref, &borrowed_locals_results);
|
dataflow::ResultsCursor::new(body_ref, &borrowed_locals_results);
|
||||||
|
@ -484,6 +486,7 @@ fn locals_live_across_suspend_points(
|
||||||
// Calculate the liveness of MIR locals ignoring borrows.
|
// Calculate the liveness of MIR locals ignoring borrows.
|
||||||
let mut liveness = MaybeLiveLocals
|
let mut liveness = MaybeLiveLocals
|
||||||
.into_engine(tcx, body_ref, def_id)
|
.into_engine(tcx, body_ref, def_id)
|
||||||
|
.pass_name("generator")
|
||||||
.iterate_to_fixpoint()
|
.iterate_to_fixpoint()
|
||||||
.into_results_cursor(body_ref);
|
.into_results_cursor(body_ref);
|
||||||
|
|
||||||
|
|
|
@ -87,6 +87,7 @@ impl<'tcx> LateLintPass<'tcx> for RedundantClone {
|
||||||
|
|
||||||
let maybe_storage_live_result = MaybeStorageLive
|
let maybe_storage_live_result = MaybeStorageLive
|
||||||
.into_engine(cx.tcx, mir, def_id.to_def_id())
|
.into_engine(cx.tcx, mir, def_id.to_def_id())
|
||||||
|
.pass_name("redundant_clone")
|
||||||
.iterate_to_fixpoint()
|
.iterate_to_fixpoint()
|
||||||
.into_results_cursor(mir);
|
.into_results_cursor(mir);
|
||||||
let mut possible_borrower = {
|
let mut possible_borrower = {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue