<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62128>62128</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[MLIR] `--view-op-graph` doesn't handle graph regions (backedges)
</td>
</tr>
<tr>
<th>Labels</th>
<td>
good first issue,
mlir
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
mortbopet
</td>
</tr>
</table>
<pre>
As a trivial example, consider the following:
```mlir
module {
%add = arith.addi %c0, %c1 : index
%c0 = arith.constant 0 : index
%c1 = arith.constant 1 : index
}
```
renders the following .dot graph: `mlir-opt --view-op-graph`:
```dot
digraph G {
compound = true;
subgraph cluster_1 {
v2 [label = " ", shape = plain];
label = "builtin.module : ())\n";
subgraph cluster_3 {
v4 [label = " ", shape = plain];
label = "";
v5 [label = "arith.addi : (index))\n", shape = ellipse];
v6 [label = "arith.constant : (index))\n\nvalue: 0 : index", shape = ellipse];
v7 [label = "arith.constant : (index))\n\nvalue: 1 : index", shape = ellipse];
}
}
v0 -> v5 [label = "0", style = solid];
v0 -> v5 [label = "1", style = solid];
}
```
![image](https://user-images.githubusercontent.com/16338943/232007115-bdf6b9a2-a656-4981-8135-ab796483eb7b.png)
I suspect the only required change to the `view-op-graph` pass will be to do a pre-pass on all ops in a region, assign node names to them, and _then_ iterate and emit the operations.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVctu6zYTfhp6M5BAUveFFkn8-8cB2k1fIKDEscSWIlWSUk7evqDknNhx0hsKyDI1l--bGQ6Hwns1GMSWFI-kOB7EEkbr2sm60NkZw6Gz8rV98CAgOLUqoQG_i2nWSPgT9NZ4JdFBGBHOVmv7osxAsgdCj4S-vUu6P5NWbhdNVi4agVSP-zcA4YWQEkh2BOFUGFMhpYrSnkaiuGBAsgdQRuL3K6-eXjnFeIIwAejntuwz2ztcUh0_RH6djkMj0fnblCGVNsDgxDxGsEuyiZ0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