Skip to content

Commit 5e73196

Browse files
committed
how much do the tricolor dfs + sccs cost?
1 parent a8615b3 commit 5e73196

File tree

2 files changed

+19
-15
lines changed
  • compiler
    • rustc_borrowck/src
    • rustc_mir_dataflow/src/framework

2 files changed

+19
-15
lines changed

compiler/rustc_borrowck/src/lib.rs

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -438,13 +438,24 @@ fn do_mir_borrowck<'tcx>(
438438

439439
let (mut flow_analysis, flow_entry_states) =
440440
get_flow_results(tcx, body, &move_data, &borrow_set, &regioncx);
441-
visit_results(
442-
body,
443-
traversal::reverse_postorder(body).map(|(bb, _)| bb),
444-
&mut flow_analysis,
445-
&flow_entry_states,
446-
&mut mbcx,
447-
);
441+
if body.basic_blocks.is_cfg_cyclic() {
442+
let _sccs = body.basic_blocks.sccs();
443+
visit_results(
444+
body,
445+
traversal::reverse_postorder(body).map(|(bb, _)| bb),
446+
&mut flow_analysis,
447+
&flow_entry_states,
448+
&mut mbcx,
449+
);
450+
} else {
451+
visit_results(
452+
body,
453+
traversal::reverse_postorder(body).map(|(bb, _)| bb),
454+
&mut flow_analysis,
455+
&flow_entry_states,
456+
&mut mbcx,
457+
);
458+
}
448459

449460
mbcx.report_move_errors();
450461

compiler/rustc_mir_dataflow/src/framework/mod.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -240,14 +240,7 @@ pub trait Analysis<'tcx> {
240240
Self: Sized,
241241
Self::Domain: DebugWithContext<Self>,
242242
{
243-
// Computing dataflow over the SCCs is only supported in forward analyses. It's also
244-
// unnecessary to use it on acyclic graphs, as the condensation graph is of course the same
245-
// as the CFG itself.
246-
if Self::Direction::IS_BACKWARD || !body.basic_blocks.is_cfg_cyclic() {
247-
self.iterate_to_fixpoint_per_block(tcx, body, pass_name)
248-
} else {
249-
self.iterate_to_fixpoint_per_scc(tcx, body, pass_name)
250-
}
243+
self.iterate_to_fixpoint_per_block(tcx, body, pass_name)
251244
}
252245

253246
/* Extension methods */

0 commit comments

Comments
 (0)