@@ -55,12 +55,12 @@ where
5555
5656 // Nodes
5757 for ( block, _) in body. basic_blocks ( ) . iter_enumerated ( ) {
58- write_node ( block, body, w) ?;
58+ write_node ( def_id , block, body, w) ?;
5959 }
6060
6161 // Edges
6262 for ( source, _) in body. basic_blocks ( ) . iter_enumerated ( ) {
63- write_edges ( source, body, w) ?;
63+ write_edges ( def_id , source, body, w) ?;
6464 }
6565 writeln ! ( w, "}}" )
6666}
@@ -115,21 +115,33 @@ pub fn write_node_label<W: Write, INIT, FINI>(block: BasicBlock,
115115}
116116
117117/// Write a graphviz DOT node for the given basic block.
118- fn write_node < W : Write > ( block : BasicBlock , body : & Body < ' _ > , w : & mut W ) -> io:: Result < ( ) > {
118+ fn write_node < W : Write > (
119+ def_id : DefId ,
120+ block : BasicBlock ,
121+ body : & Body < ' _ > ,
122+ w : & mut W ,
123+ ) -> io:: Result < ( ) > {
119124 // Start a new node with the label to follow, in one of DOT's pseudo-HTML tables.
120- write ! ( w, r#" {} [shape="none", label=<"# , node( block) ) ?;
125+ write ! ( w, r#" {} [shape="none", label=<"# , node( def_id , block) ) ?;
121126 write_node_label ( block, body, w, 1 , |_| Ok ( ( ) ) , |_| Ok ( ( ) ) ) ?;
122127 // Close the node label and the node itself.
123128 writeln ! ( w, ">];" )
124129}
125130
126131/// Write graphviz DOT edges with labels between the given basic block and all of its successors.
127- fn write_edges < W : Write > ( source : BasicBlock , body : & Body < ' _ > , w : & mut W ) -> io:: Result < ( ) > {
132+ fn write_edges < W : Write > (
133+ def_id : DefId ,
134+ source : BasicBlock ,
135+ body : & Body < ' _ > ,
136+ w : & mut W ,
137+ ) -> io:: Result < ( ) > {
128138 let terminator = body[ source] . terminator ( ) ;
129139 let labels = terminator. kind . fmt_successor_labels ( ) ;
130140
131141 for ( & target, label) in terminator. successors ( ) . zip ( labels) {
132- writeln ! ( w, r#" {} -> {} [label="{}"];"# , node( source) , node( target) , label) ?;
142+ let src = node ( def_id, source) ;
143+ let trg = node ( def_id, target) ;
144+ writeln ! ( w, r#" {} -> {} [label="{}"];"# , src, trg, label) ?;
133145 }
134146
135147 Ok ( ( ) )
@@ -181,8 +193,8 @@ fn write_graph_label<'tcx, W: Write>(
181193 writeln ! ( w, ">;" )
182194}
183195
184- fn node ( block : BasicBlock ) -> String {
185- format ! ( "bb{}" , block. index( ) )
196+ fn node ( def_id : DefId , block : BasicBlock ) -> String {
197+ format ! ( "bb{}__{} " , block. index( ) , graphviz_safe_def_name ( def_id ) )
186198}
187199
188200fn escape < T : Debug > ( t : & T ) -> String {
0 commit comments