Skip to content

[mlir][test] Fix UNREACHABLE in TestInlinerInterface for multi-block inlining#186266

Merged
joker-eph merged 1 commit into
llvm:mainfrom
joker-eph:fix/issue-185350
Mar 12, 2026
Merged

[mlir][test] Fix UNREACHABLE in TestInlinerInterface for multi-block inlining#186266
joker-eph merged 1 commit into
llvm:mainfrom
joker-eph:fix/issue-185350

Conversation

@joker-eph

Copy link
Copy Markdown
Contributor

When the MLIR inliner inlines a callable region that has more than one block, it calls handleTerminator(op, Block *newDest) for the terminator of every inlined block. TestInlinerInterface only implemented the single-block variant (handleTerminator(op, ValueRange)), so the default llvm_unreachable was hit when inlining a test.functional_region_op whose body contained multiple blocks (e.g. an explicit cf.br jump to a successor block whose terminator was test.return).

Fix: add the missing handleTerminator(op, Block *) override to TestInlinerInterface. Mirror the pattern used by FuncDialectInlinerExtension: if the terminator is a TestReturnOp, replace it with a cf.br to newDest carrying the return operands. Any other terminator (e.g. cf.br for intra-region branches) is left untouched — the existing ControlFlowInlinerInterface no-op already handles those correctly.

Add a regression test in test/Transforms/inlining.mlir that inlines a call_indirect into a test.functional_region_op with two blocks.

Fixes #185350

Assisted-by: Claude Code

…inlining

When the MLIR inliner inlines a callable region that has more than one
block, it calls `handleTerminator(op, Block *newDest)` for the terminator
of every inlined block.  `TestInlinerInterface` only implemented the
single-block variant (`handleTerminator(op, ValueRange)`), so the
default `llvm_unreachable` was hit when inlining a `test.functional_region_op`
whose body contained multiple blocks (e.g. an explicit `cf.br` jump to a
successor block whose terminator was `test.return`).

Fix: add the missing `handleTerminator(op, Block *)` override to
`TestInlinerInterface`.  Mirror the pattern used by
`FuncDialectInlinerExtension`: if the terminator is a `TestReturnOp`,
replace it with a `cf.br` to `newDest` carrying the return operands.
Any other terminator (e.g. `cf.br` for intra-region branches) is left
untouched — the existing `ControlFlowInlinerInterface` no-op already
handles those correctly.

Add a regression test in `test/Transforms/inlining.mlir` that inlines a
`call_indirect` into a `test.functional_region_op` with two blocks.

Fixes llvm#185350

Assisted-by: Claude Code
@joker-eph joker-eph added the skip-precommit-approval PR for CI feedback, not intended for review label Mar 12, 2026
@joker-eph joker-eph enabled auto-merge (squash) March 12, 2026 22:18
@llvmbot llvmbot added the mlir label Mar 12, 2026
@joker-eph joker-eph merged commit 2d70dbd into llvm:main Mar 12, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mlir skip-precommit-approval PR for CI feedback, not intended for review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MLIR][Inliner] UNREACHABLE in handleTerminator when inlining function containing multi-block functional_region_op

2 participants