[Mlir-commits] [mlir] [mlir][transforms] Process RegionBranchOp with empty region (PR #123895)
Mehdi Amini
llvmlistbot at llvm.org
Fri Jan 31 10:41:23 PST 2025
joker-eph wrote:
Regions can't be dynamically added, they are fixed after creation, which is why the convention has been for ops like scf.if to create both regions immediately. Adding a block and a yield is "not free" and in general we avoided consuming extra resources when not needed, hence the convention about empty regions.
`scf.if` isn't the only case, for example a function declaration has an empty region as well. This is even codified in the Parser API somehow with the `parseOptionalRegion()` API which follows the pattern in general of:
```
auto *body = result.addRegion();
OptionalParseResult parseResult =
parser.parseOptionalRegion(*body, ...);
```
https://github.com/llvm/llvm-project/pull/123895
More information about the Mlir-commits
mailing list