Skip to content

Conversation

@vaivaswatha
Copy link
Contributor

@vaivaswatha vaivaswatha commented Nov 11, 2025

Closes #4517


Note

Make IR printing deterministic by deriving stable SSA names and emitting constants separately; normalize metadata/operand printing, remove inlined folded instructions, and update tests and snapshots accordingly.

  • Printer determinism and naming: Reworked sway-ir/src/printer.rs to make SSA value names deterministic by deriving Namer::default_name() from slotmap::Key::data() (e.g., v<idx>v<gen>), and introduced maybe_constant_to_doc to emit constant definitions once and refer to them by stable IDs. Adjusted instruction printing to emit constant definitions separately and to reference them via generated IDs, improving reproducibility.
  • Constant folding output: combine_cmp now replaces folded compare instructions with a standalone constant and removes the original instruction; tests updated to match const <ty> <value> and to use $ID/$VAR regex placeholders rather than brittle v0 literals.
  • Metadata printing normalization: Simplified Metadatum textual format (e.g., !1 = !0, a_struct …, (… …)), ensuring stable, concise output; MetadataNamer now assigns deterministic indices.
  • Test updates and golden outputs: Updated numerous IR/CSE/DCE/inline/serialize tests to use regex placeholders (e.g., regex: VAR=v\d+v\d+, $ID = …, $VAR reuse) and to expect separate constant definitions and stable value IDs. Regenerated E2E snapshots (e.g., array_repeat, logging, transmute, main_args) reflecting new deterministic naming.
  • Minor cleanups: Tweaked constants.rs test expectations; adjusted get_storage_key and store/load prints to reference $VAR placeholders; added slotmap::Key import.

Written by Cursor Bugbot for commit 00b14d7. This will update automatically on new commits. Configure here.

@vaivaswatha vaivaswatha self-assigned this Nov 11, 2025
@vaivaswatha vaivaswatha marked this pull request as ready for review November 12, 2025 07:44
@vaivaswatha vaivaswatha requested a review from a team as a code owner November 12, 2025 07:44
@vaivaswatha vaivaswatha enabled auto-merge (squash) November 13, 2025 07:13
@vaivaswatha vaivaswatha requested a review from a team November 13, 2025 11:22
xunilrj
xunilrj previously approved these changes Nov 13, 2025
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the final PR Bugbot will review for you during this billing cycle

Your free Bugbot reviews will reset on December 7

Details

Your team is on the Bugbot Free tier. On this plan, Bugbot will review limited PRs each billing cycle for each member of your team.

To receive Bugbot reviews on all of your PRs, visit the Cursor dashboard to activate Pro and start your 14-day free trial.

@vaivaswatha vaivaswatha requested review from a team and xunilrj November 19, 2025 06:19
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.

Support single instructions and custom value names in IR printer

3 participants