[mlir][test] Fix UNREACHABLE in TestInlinerInterface for multi-block inlining#186266
Merged
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.TestInlinerInterfaceonly implemented the single-block variant (handleTerminator(op, ValueRange)), so the defaultllvm_unreachablewas hit when inlining atest.functional_region_opwhose body contained multiple blocks (e.g. an explicitcf.brjump to a successor block whose terminator wastest.return).Fix: add the missing
handleTerminator(op, Block *)override toTestInlinerInterface. Mirror the pattern used byFuncDialectInlinerExtension: if the terminator is aTestReturnOp, replace it with acf.brtonewDestcarrying the return operands. Any other terminator (e.g.cf.brfor intra-region branches) is left untouched — the existingControlFlowInlinerInterfaceno-op already handles those correctly.Add a regression test in
test/Transforms/inlining.mlirthat inlines acall_indirectinto atest.functional_region_opwith two blocks.Fixes #185350
Assisted-by: Claude Code