Fix crash on non-empty return_void blocks#323
Open
ShangkunLi wants to merge 1 commit into
Open
Conversation
tancheng
reviewed
Jun 10, 2026
tancheng
left a comment
Contributor
There was a problem hiding this comment.
Why we don't need to update any tests? They all already passed?
Comment on lines
-346
to
-349
| // TODO: Handle non-empty return blocks. | ||
| // The basic idea is to create a new block that only contains the | ||
| // return_void operation, and redirect the original return block to | ||
| // this new block. |
Contributor
There was a problem hiding this comment.
Why we previously want a standalone bb only containing return? Can you recall?
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.
The --canonicalize-return pass previously assumed that every block containing a neura.return_void operation was an empty block (i.e., return_void was the only operation in it). When this assumption was violated — which happens for real-world kernels where other operations share the same basic block as return_void — the pass hit an unconditional assert(false) and crashed:
This made the pass fail on a broad class of benchmarks (fir, conv, spmv, jacobi, etc.) that produce non-empty return_void blocks after lowering.
Fix:
is_empty_blockguard and the failing assert in both call sites insideprocessVoidReturnsInKernelandCanonicalizeReturnPass.processEmptyReturnVoidBlock→processReturnVoidBlockto reflect that it now handles the general case.