From c5fe1d53c7d9d82117663b504f39ffe233f69a04 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Tue, 16 Mar 2021 21:47:14 -0400 Subject: [PATCH] [dot] function calls --- src/back/dot/mod.rs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/back/dot/mod.rs b/src/back/dot/mod.rs index cf5382290a..4016352485 100644 --- a/src/back/dot/mod.rs +++ b/src/back/dot/mod.rs @@ -17,6 +17,7 @@ struct StatementGraph { flow: Vec<(usize, usize, &'static str)>, dependencies: Vec<(usize, Handle, &'static str)>, emits: Vec<(usize, Handle)>, + calls: Vec<(usize, Handle)>, } impl StatementGraph { @@ -105,7 +106,7 @@ impl StatementGraph { "ImageStore" } S::Call { - function: _, + function, ref arguments, result, } => { @@ -115,7 +116,7 @@ impl StatementGraph { if let Some(expr) = result { self.emits.push((id, expr)); } - //TODO: link to function + self.calls.push((id, function)); "Call" } }; @@ -400,6 +401,15 @@ fn write_fun(output: &mut String, prefix: String, fun: &crate::Function) -> Resu to.index(), )?; } + for (from, function) in sg.calls { + writeln!( + output, + "\t\t{}_s{} -> f{}_s0", + prefix, + from, + function.index(), + )?; + } Ok(()) } @@ -427,7 +437,12 @@ pub fn write(module: &crate::Module) -> Result { for (handle, fun) in module.functions.iter() { let prefix = format!("f{}", handle.index()); writeln!(output, "\tsubgraph cluster_{} {{", prefix)?; - writeln!(output, "\t\tlabel=\"Function/'{}'\"", name(&fun.name))?; + writeln!( + output, + "\t\tlabel=\"Function{:?}/'{}'\"", + handle, + name(&fun.name) + )?; write_fun(&mut output, prefix, fun)?; writeln!(output, "\t}}")?; }