[Mlir-commits] [mlir] [mlir][Transforms] Fix crash in `CFGToSCF` when conversion fails (PR #173590)

Mehdi Amini llvmlistbot at llvm.org
Sat Feb 28 09:28:26 PST 2026


================
@@ -1156,8 +1156,10 @@ static FailureOr<SmallVector<Block *>> transformToStructuredCFBranches(
     FailureOr<Operation *> result = interface.createStructuredBranchRegionOp(
         opBuilder, regionEntry->getTerminator(),
         continuation->getArgumentTypes(), conditionalRegions);
-    if (failed(result))
+    if (failed(result)) {
+      regionEntry->getTerminator()->dropAllReferences();
----------------
joker-eph wrote:

`mlir::transformCFGToSCF` seems to have many path that will return failure after starting to transform the IR unfortunately. The whole algorithm does not seem to be setup in a way that can avoid this I think?

https://github.com/llvm/llvm-project/pull/173590


More information about the Mlir-commits mailing list