[Mlir-commits] [mlir] [mlir][CFGToSCF] Fix crash when encountering unknown control flow ops (PR #184103)
Mehdi Amini
llvmlistbot at llvm.org
Thu Mar 5 05:57:34 PST 2026
================
@@ -1156,8 +1156,18 @@ static FailureOr<SmallVector<Block *>> transformToStructuredCFBranches(
FailureOr<Operation *> result = interface.createStructuredBranchRegionOp(
opBuilder, regionEntry->getTerminator(),
continuation->getArgumentTypes(), conditionalRegions);
- if (failed(result))
+ if (failed(result)) {
+ // Blocks were moved from the parent region into conditionalRegions before
+ // calling createStructuredBranchRegionOp. On failure, move them back to
+ // avoid use-after-free crashes: the moved blocks may still be referenced
+ // as successors by blocks remaining in the parent region, so destroying
+ // conditionalRegions with live uses would trigger an assertion.
----------------
joker-eph wrote:
Yes, done!
https://github.com/llvm/llvm-project/pull/184103
More information about the Mlir-commits
mailing list