about summary refs log tree commit diff
path: root/compiler/rustc_mir/src/util
diff options
context:
space:
mode:
authorWesley Wiser <wwiser@gmail.com>2020-05-30 15:02:32 -0400
committerWesley Wiser <wwiser@gmail.com>2020-12-06 20:48:25 -0500
commit01aec8d18556be5e8d498c2f331b9015b7befde2 (patch)
tree319bf10bc8a93fda56f200deedadf76c7a534b8e /compiler/rustc_mir/src/util
parentb776d1c3e3db8befabb123ebb1e46c3531eaed46 (diff)
downloadrust-01aec8d18556be5e8d498c2f331b9015b7befde2.tar.gz
rust-01aec8d18556be5e8d498c2f331b9015b7befde2.zip
[mir-opt] Allow debuginfo to be generated for a constant or a Place
Prior to this commit, debuginfo was always generated by mapping a name
to a Place. This has the side-effect that `SimplifyLocals` cannot remove
locals that are only used for debuginfo because their other uses have
been const-propagated.

To allow these locals to be removed, we now allow debuginfo to point to
a constant value. The `ConstProp` pass detects when debuginfo points to
a local with a known constant value and replaces it with the value. This
allows the later `SimplifyLocals` pass to remove the local.
Diffstat (limited to 'compiler/rustc_mir/src/util')
-rw-r--r--compiler/rustc_mir/src/util/graphviz.rs2
-rw-r--r--compiler/rustc_mir/src/util/pretty.rs2
2 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_mir/src/util/graphviz.rs b/compiler/rustc_mir/src/util/graphviz.rs
index 625f1a3e684..370010d65f0 100644
--- a/compiler/rustc_mir/src/util/graphviz.rs
+++ b/compiler/rustc_mir/src/util/graphviz.rs
@@ -220,7 +220,7 @@ fn write_graph_label<'tcx, W: Write>(
             w,
             r#"debug {} =&gt; {};<br align="left"/>"#,
             var_debug_info.name,
-            escape(&var_debug_info.place)
+            escape(&var_debug_info.value),
         )?;
     }
 
diff --git a/compiler/rustc_mir/src/util/pretty.rs b/compiler/rustc_mir/src/util/pretty.rs
index cd60602b088..b6a1b652cf6 100644
--- a/compiler/rustc_mir/src/util/pretty.rs
+++ b/compiler/rustc_mir/src/util/pretty.rs
@@ -495,7 +495,7 @@ fn write_scope_tree(
 
         let indented_debug_info = format!(
             "{0:1$}debug {2} => {3:?};",
-            INDENT, indent, var_debug_info.name, var_debug_info.place,
+            INDENT, indent, var_debug_info.name, var_debug_info.value,
         );
 
         writeln!(