Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 812d4bb

Browse files
Fix dataflow assert errors
1 parent 8a3e2b7 commit 812d4bb

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

compiler/rustc_mir/src/transform/dest_prop.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,7 @@ impl Conflicts {
403403
.iterate_to_fixpoint()
404404
.into_results_cursor(body);
405405

406+
let mut reachable = None;
406407
dump_mir(
407408
tcx,
408409
None,
@@ -411,15 +412,18 @@ impl Conflicts {
411412
source,
412413
body,
413414
|pass_where, w| {
415+
let reachable =
416+
reachable.get_or_insert_with(|| traversal::reachable_as_bitset(body));
417+
414418
match pass_where {
415-
PassWhere::BeforeLocation(loc) => {
419+
PassWhere::BeforeLocation(loc) if reachable.contains(loc.block) => {
416420
init.seek_before_primary_effect(loc);
417421
live.seek_after_primary_effect(loc);
418422

419423
writeln!(w, " // init: {:?}", init.get())?;
420424
writeln!(w, " // live: {:?}", live.get())?;
421425
}
422-
PassWhere::AfterTerminator(bb) => {
426+
PassWhere::AfterTerminator(bb) if reachable.contains(bb) => {
423427
let loc = body.terminator_loc(bb);
424428
init.seek_after_primary_effect(loc);
425429
live.seek_before_primary_effect(loc);
@@ -428,7 +432,7 @@ impl Conflicts {
428432
writeln!(w, " // live: {:?}", live.get())?;
429433
}
430434

431-
PassWhere::BeforeBlock(bb) => {
435+
PassWhere::BeforeBlock(bb) if reachable.contains(bb) => {
432436
init.seek_to_block_start(bb);
433437
live.seek_to_block_start(bb);
434438

@@ -437,6 +441,16 @@ impl Conflicts {
437441
}
438442

439443
PassWhere::BeforeCFG | PassWhere::AfterCFG | PassWhere::AfterLocation(_) => {}
444+
445+
PassWhere::BeforeLocation(_) | PassWhere::AfterTerminator(_) => {
446+
writeln!(w, " // init: <unreachable>")?;
447+
writeln!(w, " // live: <unreachable>")?;
448+
}
449+
450+
PassWhere::BeforeBlock(_) => {
451+
writeln!(w, " // init: <unreachable>")?;
452+
writeln!(w, " // live: <unreachable>")?;
453+
}
440454
}
441455

442456
Ok(())

0 commit comments

Comments
 (0)