Skip to content

Implement dynamic storage intrinsics#7597

Merged
ironcev merged 5 commits intomasterfrom
ironcev/dynamic-storage-add-intrinsics
Apr 17, 2026
Merged

Implement dynamic storage intrinsics#7597
ironcev merged 5 commits intomasterfrom
ironcev/dynamic-storage-add-intrinsics

Conversation

@ironcev
Copy link
Copy Markdown
Member

@ironcev ironcev commented Apr 16, 2026

Description

This PR adds compiler intrinsics for dynamic storage opcodes. It is the second step in implementing #7560.

Additionally, the PR:

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@ironcev ironcev self-assigned this Apr 16, 2026
@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 16, 2026

PR Summary

High Risk
High risk because it expands storage-related intrinsic surface area and modifies compiler typechecking and IR generation for several intrinsics, which can impact codegen correctness and purity/effects analysis.

Overview
Adds support for dynamic storage opcodes via new intrinsics (e.g. __state_load_slot, __state_store_slot, __state_update_slot, __state_preload, and cheaper __state_clear_slots) and wires them through the AST intrinsic list, semantic typechecking, IR generation, and CEI/purity effect classification.

Refactors intrinsic diagnostics by computing argument/type-argument spans and improving IntrinsicIncorrectNumArgs/TArgs error messages; also fixes IR generation to consistently return unit () for side-effect-only intrinsics like __log, __smo, and __state_clear_slots.

Updates the Sway book intrinsic reference and spellcheck dictionary, and consolidates/rewrites e2e negative tests into a new intrinsics_args_type_checking suite while extending purity tests for the new storage intrinsics.

Reviewed by Cursor Bugbot for commit b5e6a40. Bugbot is set up for automated code reviews on this repo. Configure here.

@ironcev ironcev added compiler General compiler. Should eventually become more specific as the issue is triaged compiler: ir IRgen and sway-ir including optimization passes compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen compiler: parser Everything to do with the parser compiler: codegen Everything to do with IR->ASM, register allocation, etc. labels Apr 16, 2026
@ironcev
Copy link
Copy Markdown
Member Author

ironcev commented Apr 16, 2026

👍

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Apr 16, 2026

Merging this PR will not alter performance

✅ 25 untouched benchmarks


Comparing ironcev/dynamic-storage-add-intrinsics (b5e6a40) with master (fbb524c)

Open in CodSpeed

@ironcev ironcev marked this pull request as ready for review April 16, 2026 13:01
@ironcev ironcev requested review from a team as code owners April 16, 2026 13:01
@ironcev ironcev enabled auto-merge (squash) April 16, 2026 13:01
@ironcev ironcev requested a review from Dentosal April 16, 2026 13:01
Dentosal
Dentosal previously approved these changes Apr 16, 2026
@Dentosal
Copy link
Copy Markdown
Member

LGTM on my side, but please make sure to check the cursor-bot comment above. I didn't really follow the logic but there might be a real issue.

Copy link
Copy Markdown

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit ee95aa0. Configure here.

Comment thread sway-core/src/semantic_analysis/cei_pattern_analysis.rs
@ironcev ironcev requested a review from Dentosal April 17, 2026 11:37
@ironcev ironcev merged commit e12e611 into master Apr 17, 2026
46 checks passed
@ironcev ironcev deleted the ironcev/dynamic-storage-add-intrinsics branch April 17, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

compiler: codegen Everything to do with IR->ASM, register allocation, etc. compiler: frontend Everything to do with type checking, control flow analysis, and everything between parsing and IRgen compiler: ir IRgen and sway-ir including optimization passes compiler: parser Everything to do with the parser compiler General compiler. Should eventually become more specific as the issue is triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

__smo and __log intrinsics not correctly compiled and can cause ICE

2 participants