]> git.lizzy.rs Git - rust.git/commitdiff
Dump graphviz dataflow results with flag
authorDylan MacKenzie <ecstaticmorse@gmail.com>
Sat, 28 Mar 2020 21:09:12 +0000 (14:09 -0700)
committerDylan MacKenzie <ecstaticmorse@gmail.com>
Sat, 28 Mar 2020 21:09:12 +0000 (14:09 -0700)
src/librustc_mir/dataflow/framework/engine.rs

index d32072125b3b9fcd101dfbc5bea2de536a0382e3..54263287e0228f44e0e9bde16031c8eb7a366049 100644 (file)
@@ -15,6 +15,7 @@
 
 use super::graphviz;
 use super::{Analysis, GenKillAnalysis, GenKillSet, Results};
+use crate::util::pretty::dump_enabled;
 
 /// A solver for dataflow problems.
 pub struct Engine<'a, 'tcx, A>
@@ -400,12 +401,25 @@ fn write_graphviz_results<A>(
     let attrs = match RustcMirAttrs::parse(tcx, def_id) {
         Ok(attrs) => attrs,
 
-        // Invalid `rustc_mir` attrs will be reported using `span_err`.
+        // Invalid `rustc_mir` attrs are reported in `RustcMirAttrs::parse`
         Err(()) => return Ok(()),
     };
 
     let path = match attrs.output_path(A::NAME) {
         Some(path) => path,
+
+        None if tcx.sess.opts.debugging_opts.dump_mir_dataflow
+            && dump_enabled(tcx, A::NAME, def_id) =>
+        {
+            let mut path = PathBuf::from(&tcx.sess.opts.debugging_opts.dump_mir_dir);
+
+            let item_name = ty::print::with_forced_impl_filename_line(|| {
+                tcx.def_path(def_id).to_filename_friendly_no_crate()
+            });
+            path.push(format!("rustc.{}.{}.dot", item_name, A::NAME));
+            path
+        }
+
         None => return Ok(()),
     };