Skip to content

fix(transform): give a final br_if its fall-through edge - #365

Merged
siyul-park merged 3 commits into
mainfrom
fix/ssa-final-br-if
Nov 21, 2026
Merged

siyul-park merged 3 commits into
mainfrom
fix/ssa-final-br-if

Conversation

@siyul-park

Copy link
Copy Markdown
Owner

Summary

SSAPass panicked (index out of range [1] with length 1 in emitter.close) on module code whose last instruction is a br_if.

split added the exit span at len(code) only when some branch targeted that offset. A final br_if falls through to the end without targeting it, so successors found no span for the fall-through, the TermBrIf carried one edge, and emission indexed Edges[1]. past now also reports a final br_if, so the exit span exists and the branch gets both edges.

Fixes #363

Test plan

  • TestSSAPass_Run case "backward branch at the end": panicked before the fix, round-trips with identical execution results after
  • Issue repro through optimize.New(optimize.O3): no error, output passes program.Verify (checked with a throwaway test, not committed)
  • go test ./internal/transform ./optimize ./analysis ./interp
  • make check, git diff --check
  • Benchmarks not run: the change only affects code that ends in br_if

🤖 Generated with Claude Code

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>
@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: d887d2c4-8659-42eb-a219-79dc5fec4ef8
Commits

Reviewing files that changed from the base of the PR and between 8734b0f and 4d8ed99.

Files selected for processing: 3

  • docs/benchmarks.md
  • internal/transform/span.go
  • internal/transform/ssa_test.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

Share

@siyul-park
siyul-park merged commit 01e1be1 into main Nov 21, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

transform: SSAPass panics on module code that ends with a backward br_if

1 participant