[all-commits] [llvm/llvm-project] 8b15fc: [CIR] Fix FlattenCFG pattern rewriter contract vio...

Bruno Cardoso Lopes via All-commits all-commits at lists.llvm.org
Thu Apr 16 11:05:52 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 8b15fc14f5314ceb8576629f3190d4c740590396
      https://github.com/llvm/llvm-project/commit/8b15fc14f5314ceb8576629f3190d4c740590396
  Author: Bruno Cardoso Lopes <bruno.cardoso at gmail.com>
  Date:   2026-04-16 (Thu, 16 Apr 2026)

  Changed paths:
    M clang/lib/CIR/Dialect/Transforms/FlattenCFG.cpp

  Log Message:
  -----------
  [CIR] Fix FlattenCFG pattern rewriter contract violations (#192359)

Fix patterns in CIRFlattenCFGPass that modify IR but return failure(),
violating the MLIR greedy pattern rewriter contract. The contract
requires that if a pattern modifies IR, it must return success().

- CIRCleanupScopeOpFlattening: always return success() since IR is
modified (blocks split, regions inlined) before error paths
- Ternary op flattening: return success() instead of falling through
after emitError, since splitBlock/createBlock already modified IR
- Use rewriter.moveOpBefore() instead of direct defOp->moveBefore() to
properly notify the rewriter of IR mutations

Found by MLIR_ENABLE_EXPENSIVE_PATTERN_API_CHECKS=ON.
Test: flatten-cleanup-scope-nyi.cir (a silly one since it's testing an
error, but point still valid)



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