<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/112146>112146</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [mlir][bug] func::ReturnOp::getSuccessorRegions always asserts
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            mlir,
            mlir::func
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          fabianmcg
      </td>
    </tr>
</table>

<pre>
    Currently `ReturnLike` attaches `RegionBranchTerminatorOpInterface` as a sub trait (see https://github.com/llvm/llvm-project/blob/main/mlir/include/mlir/Interfaces/ControlFlowInterfaces.td#L384). Consequently, `func::ReturnOp` implements `RegionBranchTerminatorOpInterface`. However, `func::FuncOp` doesn't implement `RegionBranchOpInterface` (see https://github.com/fabianmcg/llvm-project/blob/main/mlir/include/mlir/Dialect/Func/IR/FuncOps.td#L226-L229), resulting on an assert produced by the default implementation of `RegionBranchTerminatorOpInterface`:
```
      "void", "getSuccessorRegions",
      (ins "::llvm::ArrayRef<::mlir::Attribute>":$operands,
 "::llvm::SmallVectorImpl<::mlir::RegionSuccessor> &":$regions), [{}],
 /*defaultImplementation=*/[{
        ::mlir::Operation *op = $_op;
 ::llvm::cast<::mlir::RegionBranchOpInterface>(op->getParentOp())
 .getSuccessorRegions(op->getParentRegion(), regions);
 }]
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyclFuPqzYQxz_N5MXaiAwQ4IGHbLKoK6201Z6qr5WBCXFrbGqbXeXbV7Zz2c1J1dODkPCFufx_Hg-3VgyKqIb8EfLdgs_uoE29563gauyGRav7Y72djSHl5JHBOnkjNxv1Iv4iWCeMO8e7A9m4MwitHg1X3eE3MqNQ3GnzOj0rR2bPu2hgGWd2bpkzXDgGWFoidnBuspBuABvAZhDuMLfLTo-AjZTv58_DZPSf1DnAppW6BWxGLpT_SGEAG6E6Ofd0XbhEtoDNVitntGyk_riuL10PmL6kZQZYLdlWK0t_z0Es4Nar2s-q85mlm6j8dfIyxDhJGkm5H1a-ZL_oD3on853fZlZd9NprsgqwcFf_t-5vcP43v8tZ_izEneAy_u8T9VTfTuPX6cwPcf3wgliBf7fMkJ2lE2pgWjGuGLeWjGOT0f3cUc_aI3MHYj3t-Sw_ieVOaMX0_keZesXJDpKNH8c3TFl4APFdix4QA3LEgdy3uevIWm2iexs3v1qVQln_ezydUH9htDGGH99oD-k2LgRAccs5I9rZEaRPJ0vM9ESGq95eA9xx-m3kUv5OndPmeZzkHd8x00vikD4xwPUlijkLCeT9PS4eodhBvvsctwHcnHA_f6EN6Q4w1E20_ESCsdtUXr2icEaAGz0xSHcMMPtDT5CeTW8Fdty6f1X1fU17fqWeHiB9Gsj9yn3jeZ0AS4jVFYMs7x7lrV3cONv6sryguqYbUX2tokVfp32VVnxB9arAssyyIisXh7pYU9FhiklXYJalxbqqVnlFOWKedcm6W4gaE8xWySpdlWmVlMu8T9dVVlQJz6s8Rw5ZQiMXcukJLbUZFsLamerVClfZeiF5S9KGdowYL2Ao0NMkoAudA9H3a1OHK93Og4UskcI6e3XshJOhswfTfAf5YzsPkO_YnZ4WZneoMi4_-NGerrBdzEbW_7tbB4m-B59Uvtf4TwAAAP__IK8BiQ">