Skip to content

refactor(ssa): drop the dead Shape.Host field and move OverflowsI64 to LICM - #346

Merged
siyul-park merged 2 commits into
mainfrom
refactor/ssa-surface
Nov 19, 2026
Merged

siyul-park merged 2 commits into
mainfrom
refactor/ssa-surface

Conversation

@siyul-park

@siyul-park siyul-park commented Nov 19, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Delete ssa.Shape.Host: never set outside format_test.go, only printed.
  • Move ssa.OverflowsI64 (one caller, transform/licm.go hoistable) into LICM as private overflows.
  • Replace TestOverflowsI64 with a LICM contract case: a loop-invariant i64.add stays in the loop. Mutation-checked: removing the overflows test from hoistable turns it red.

First of five structural cleanups from a review of the bytecode → SSA → optimize → native pipeline.

Test plan

  • go test ./internal/ssa ./internal/transform
  • make check
  • git diff --check

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Loop optimizations now keep certain arithmetic operations inside the loop when moving them could change their behavior. This helps preserve correct results for values that exceed the supported numeric range.
  • Refactor
    • Updated internal handling of shape formatting and arithmetic checks. These changes do not alter the remaining shape details or the formatted output for them.

…o LICM

Shape.Host was never set outside a format test; it only reached the
printer. OverflowsI64 is an opcode fact with one caller, LICM's hoistable,
so it becomes LICM's private overflows. Its contract is now pinned at the
public boundary: LICM keeps a loop-invariant i64.add in the loop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

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: 5a12644a-5b02-402e-a982-a137f36d502e

No actionable comments were generated in the recent review.

Walkthrough

The changes remove host-kind metadata from SSA shapes and their formatted output. LICM now uses a local helper to classify overflow-capable opcodes, and a regression test checks that it does not hoist a potentially overflowing loop-invariant I64_ADD.

Changes: SSA Shape Metadata

Layer / File(s) Summary
Remove shape host metadata
internal/ssa/operation.go, internal/ssa/format.go, internal/ssa/format_test.go
Shape no longer has a Host field, and shape formatting no longer prints a host value. The struct-shape test no longer sets or expects Host.

LICM Overflow Checks

Layer / File(s) Summary
Local overflow classification and LICM regression
internal/transform/licm.go, internal/transform/licm_test.go, internal/ssa/operation.go, internal/ssa/operation_test.go
LICM uses a local overflows helper to classify arithmetic and shift opcodes. The exported ssa.OverflowsI64 helper and its test are removed. A regression test checks that a potentially overflowing invariant I64_ADD stays in the loop body and that the transformed function verifies.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Merge Risk: Minimal · previous review 4d263

This is a structural cleanup. It removes unused shape metadata and keeps the loop optimizer's overflow-aware hoisting behavior, now covered by a regression test. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the two main changes: removing the unused Shape.Host field and moving OverflowsI64 into LICM. It follows conventional commit style and matches the changeset. It is specific enough for …
Description check Passed The description covers the changes made (removing Shape.Host, moving OverflowsI64 into LICM as overflows, replacing TestOverflowsI64 with a LICM regression case) and the test plan with checks run. It …
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the two main changes: removing the unused Shape.Host field and moving OverflowsI64 into LICM. It follows conventional commit style and matches the changeset. It is specific enough for a reader scanning history.

Full details: Description check

Explanation

The description covers the changes made (removing Shape.Host, moving OverflowsI64 into LICM as overflows, replacing TestOverflowsI64 with a LICM regression case) and the test plan with checks run. It does not use the template's section headings (Changes Made, Related Issues, Additional Information). Related Issues is missing, and Additional Information is only partly covered by the note about the five-part cleanup series.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • 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

Recent review info

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: 20ff5dd0-f8a0-40c2-9b5f-da66db0cd7a9
Commits

Reviewing files that changed from the base of the PR and between af86a70 and 4d26392.

Files selected for processing: 6

  • internal/ssa/format.go
  • internal/ssa/format_test.go
  • internal/ssa/operation.go
  • internal/ssa/operation_test.go
  • internal/transform/licm.go
  • internal/transform/licm_test.go
Files with no reviewable changes: 3

  • internal/ssa/format.go
  • internal/ssa/operation.go
  • internal/ssa/operation_test.go

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

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.

1 participant