Repository navigation
fix(transform): give a final br_if its fall-through edge - #365
Merged
Merged
Conversation
split created the exit span at the end of the code only when a branch targeted that offset. A br_if as the last instruction falls through to the end without targeting it, so its terminator carried one edge and the emitter indexed term.Edges[1] out of range. past now also reports a final br_if, so the exit span exists and the branch gets both edges. Fixes #363 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 35 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
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.
Summary
SSAPasspanicked (index out of range [1] with length 1inemitter.close) on module code whose last instruction is abr_if.splitadded the exit span atlen(code)only when some branch targeted that offset. A finalbr_iffalls through to the end without targeting it, sosuccessorsfound no span for the fall-through, theTermBrIfcarried one edge, and emission indexedEdges[1].pastnow also reports a finalbr_if, so the exit span exists and the branch gets both edges.Fixes #363
Test plan
TestSSAPass_Runcase "backward branch at the end": panicked before the fix, round-trips with identical execution results afteroptimize.New(optimize.O3): no error, output passesprogram.Verify(checked with a throwaway test, not committed)go test ./internal/transform ./optimize ./analysis ./interpmake check,git diff --checkbr_if🤖 Generated with Claude Code