about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJonas Schievink <jonasschievink@gmail.com>2020-09-12 14:58:52 +0200
committerJonas Schievink <jonasschievink@gmail.com>2020-09-18 21:23:00 +0200
commit812d4bbc8d1a240ecc900ffafacb5ce34f69e9f3 (patch)
treeb8aa2ffb5c66a34837e21d89a65842b4797b3f4b
parent8a3e2b78bb0595bc9205b29898eb128836b5c57f (diff)
Fix dataflow assert errors
-rw-r--r--compiler/rustc_mir/src/transform/dest_prop.rs20
1 files changed, 17 insertions, 3 deletions
diff --git a/compiler/rustc_mir/src/transform/dest_prop.rs b/compiler/rustc_mir/src/transform/dest_prop.rs
index 19054f36171..3c46e8fc36b 100644
--- a/compiler/rustc_mir/src/transform/dest_prop.rs
+++ b/compiler/rustc_mir/src/transform/dest_prop.rs
@@ -403,6 +403,7 @@ impl Conflicts {
             .iterate_to_fixpoint()
             .into_results_cursor(body);
 
+        let mut reachable = None;
         dump_mir(
             tcx,
             None,
@@ -411,15 +412,18 @@ impl Conflicts {
             source,
             body,
             |pass_where, w| {
+                let reachable =
+                    reachable.get_or_insert_with(|| traversal::reachable_as_bitset(body));
+
                 match pass_where {
-                    PassWhere::BeforeLocation(loc) => {
+                    PassWhere::BeforeLocation(loc) if reachable.contains(loc.block) => {
                         init.seek_before_primary_effect(loc);
                         live.seek_after_primary_effect(loc);
 
                         writeln!(w, "        // init: {:?}", init.get())?;
                         writeln!(w, "        // live: {:?}", live.get())?;
                     }
-                    PassWhere::AfterTerminator(bb) => {
+                    PassWhere::AfterTerminator(bb) if reachable.contains(bb) => {
                         let loc = body.terminator_loc(bb);
                         init.seek_after_primary_effect(loc);
                         live.seek_before_primary_effect(loc);
@@ -428,7 +432,7 @@ impl Conflicts {
                         writeln!(w, "        // live: {:?}", live.get())?;
                     }
 
-                    PassWhere::BeforeBlock(bb) => {
+                    PassWhere::BeforeBlock(bb) if reachable.contains(bb) => {
                         init.seek_to_block_start(bb);
                         live.seek_to_block_start(bb);
 
@@ -437,6 +441,16 @@ impl Conflicts {
                     }
 
                     PassWhere::BeforeCFG | PassWhere::AfterCFG | PassWhere::AfterLocation(_) => {}
+
+                    PassWhere::BeforeLocation(_) | PassWhere::AfterTerminator(_) => {
+                        writeln!(w, "        // init: <unreachable>")?;
+                        writeln!(w, "        // live: <unreachable>")?;
+                    }
+
+                    PassWhere::BeforeBlock(_) => {
+                        writeln!(w, "    // init: <unreachable>")?;
+                        writeln!(w, "    // live: <unreachable>")?;
+                    }
                 }
 
                 Ok(())