[all-commits] [llvm/llvm-project] 03174c: [mlir][CFGToSCF] Fix crash when encountering unkno...

Mehdi Amini via All-commits all-commits at lists.llvm.org
Thu Mar 5 06:12:27 PST 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 03174c2b14629293da2959d44e9f82f7bc6b15b2
      https://github.com/llvm/llvm-project/commit/03174c2b14629293da2959d44e9f82f7bc6b15b2
  Author: Mehdi Amini <joker.eph at gmail.com>
  Date:   2026-03-05 (Thu, 05 Mar 2026)

  Changed paths:
    M mlir/lib/Transforms/Utils/CFGToSCF.cpp
    A mlir/test/Conversion/ControlFlowToSCF/unknown-cf-op.mlir

  Log Message:
  -----------
  [mlir][CFGToSCF] Fix crash when encountering unknown control flow ops (#184103)

When transformToStructuredCFBranches encountered a control flow op not
handled by the CFGToSCFInterface (e.g., spirv.BranchConditional with
--lift-cf-to-scf), it correctly emitted an error and returned failure.
However, blocks had already been moved from the parent region into
temporary local Region objects before the failure was detected.

When those temporary Region objects went out of scope, their destructor
tried to destroy the contained blocks. But those blocks still had live
predecessor references from the parent region (the regionEntry's
terminator still pointed to them), causing an assertion failure:
  use_empty() && "Cannot destroy a value that still has uses\!"

Fix: on failure from createStructuredBranchRegionOp, move the blocks
from the temporary conditionalRegions back into the parent region before
returning failure. This restores IR consistency and allows the Region
destructor to run safely.

Fixes #120883
Fixes #118454

Assisted-by: Claude Code



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list