Skip to content

(refactor): preserve partial struct construct info during merge with FieldVar placeholders#9804

Merged
eytan-starkware merged 1 commit intomainfrom
eytan_graphite/_refactor_preserve_partial_struct_construct_info_during_merge_with_fieldvar_placeholders
Apr 23, 2026
Merged

(refactor): preserve partial struct construct info during merge with FieldVar placeholders#9804
eytan-starkware merged 1 commit intomainfrom
eytan_graphite/_refactor_preserve_partial_struct_construct_info_during_merge_with_fieldvar_placeholders

Conversation

@eytan-starkware
Copy link
Copy Markdown
Contributor

@eytan-starkware eytan-starkware commented Mar 30, 2026

Summary

Introduces placeholder support in equality analysis for struct fields to handle unknown fields during control flow merges. When merging equality states from different branches, fields that don't have intersection representatives are now represented as placeholders instead of being dropped, preserving partial struct information.


Type of change

Please check one:

  • Bug fix (fixes incorrect behavior)
  • New feature
  • Performance improvement
  • Documentation change with concrete technical impact
  • Style, wording, formatting, or typo-only change

Why is this change needed?

Previously, when merging equality states from different control flow branches, struct fields that couldn't be unified (no intersection representative) were completely lost. This caused the analysis to lose valuable structural information about partially-known structs, reducing the effectiveness of equality tracking across complex control flows.


What was the behavior or documentation before?

Struct fields in equality analysis were represented only as real variables (VariableId). During merge operations, if a field had no intersection representative between two branches, that field information was discarded entirely, potentially losing the entire struct relationship.


What is the behavior or documentation after?

Struct fields are now represented as FieldVar enum that can be either a real variable or a globally unique placeholder. During merges, unknown fields become placeholders, preserving the struct's shape and allowing partial equality information to be maintained. Placeholders are displayed as "?" in debug output and are handled appropriately in all struct operations.


Related issue or discussion (if any)


Additional context

This change includes comprehensive updates to handle placeholders throughout the equality analysis pipeline, including struct construction/destruction, array operations, and debug formatting. The implementation ensures that placeholders are properly tracked and don't interfere with real variable relationships while preserving as much structural information as possible.

@reviewable-StarkWare
Copy link
Copy Markdown

This change is Reviewable

@eytan-starkware eytan-starkware force-pushed the eytan_graphite/_refactor_preserve_partial_struct_construct_info_during_merge_with_fieldvar_placeholders branch from 380eff7 to 4f7c2c8 Compare April 14, 2026 09:30
@eytan-starkware eytan-starkware force-pushed the eytan_graphite/refactor_unify_hashcons_reverse_maps_and_class_info_into_a_single_classinfo_struct branch from 920fe25 to d657de1 Compare April 14, 2026 09:30
@eytan-starkware eytan-starkware marked this pull request as ready for review April 14, 2026 09:32
@cursor
Copy link
Copy Markdown

cursor Bot commented Apr 14, 2026

PR Summary

Medium Risk
Changes core equality-analysis merge logic to retain partial StructConstruct relationships using synthetic placeholder fields, which could affect downstream optimizations/diagnostics that rely on this analysis. Risk is moderate due to new placeholder semantics and updated array/struct handling, but scope is limited to the lowering equality analysis and its tests.

Overview
Improves EqualityAnalysis so control-flow merges preserve partial struct/array construct information instead of dropping the whole StructConstruct relation when some fields can’t be intersected.

This introduces FieldVar (real var vs globally-unique placeholder) and threads it through relation tracking, struct construct/destructure, and array pop tracking; merge now emits placeholders for non-intersecting fields (rendered as ? in debug output). Adds a regression test demonstrating a merged struct retaining a shared field while marking the differing field unknown.

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

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4f7c2c867c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/cairo-lang-lowering/src/analysis/equality_analysis.rs Outdated
@eytan-starkware eytan-starkware force-pushed the eytan_graphite/refactor_unify_hashcons_reverse_maps_and_class_info_into_a_single_classinfo_struct branch from d657de1 to 2ee2269 Compare April 14, 2026 09:48
@eytan-starkware eytan-starkware force-pushed the eytan_graphite/_refactor_preserve_partial_struct_construct_info_during_merge_with_fieldvar_placeholders branch from 4f7c2c8 to e2dfd8a Compare April 14, 2026 09:48
Copy link
Copy Markdown
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

@orizi reviewed all commit messages and made 1 comment.
Reviewable status: 0 of 1 files reviewed, 2 unresolved discussions (waiting on eytan-starkware and TomerStarkware).


a discussion (no related file):
no tests are possible?

@eytan-starkware eytan-starkware changed the base branch from eytan_graphite/refactor_unify_hashcons_reverse_maps_and_class_info_into_a_single_classinfo_struct to graphite-base/9804 April 15, 2026 14:16
@eytan-starkware eytan-starkware force-pushed the eytan_graphite/_refactor_preserve_partial_struct_construct_info_during_merge_with_fieldvar_placeholders branch from e2dfd8a to e9939df Compare April 15, 2026 14:16
@eytan-starkware eytan-starkware changed the base branch from graphite-base/9804 to main April 15, 2026 14:17
Copy link
Copy Markdown
Contributor Author

@eytan-starkware eytan-starkware left a comment

Choose a reason for hiding this comment

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

@eytan-starkware made 2 comments.
Reviewable status: 0 of 2 files reviewed, 2 unresolved discussions (waiting on orizi and TomerStarkware).


a discussion (no related file):

Previously, orizi wrote…

no tests are possible?

They were lost but now found

Comment thread crates/cairo-lang-lowering/src/analysis/equality_analysis.rs Outdated
Copy link
Copy Markdown
Contributor Author

@eytan-starkware eytan-starkware left a comment

Choose a reason for hiding this comment

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

@eytan-starkware resolved 1 discussion.
Reviewable status: 0 of 2 files reviewed, 1 unresolved discussion (waiting on orizi and TomerStarkware).

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, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit e9939df. Configure here.

Comment thread crates/cairo-lang-lowering/src/analysis/equality_analysis.rs
Copy link
Copy Markdown
Collaborator

@TomerStarkware TomerStarkware left a comment

Choose a reason for hiding this comment

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

:lgtm:

@TomerStarkware reviewed 2 files and all commit messages, and made 1 comment.
Reviewable status: all files reviewed, 2 unresolved discussions (waiting on eytan-starkware and orizi).

Copy link
Copy Markdown
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

:lgtm:

@orizi reviewed all commit messages, made 1 comment, and resolved 1 discussion.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on eytan-starkware).

@eytan-starkware eytan-starkware force-pushed the eytan_graphite/_refactor_preserve_partial_struct_construct_info_during_merge_with_fieldvar_placeholders branch from e9939df to fae55f3 Compare April 23, 2026 12:27
Copy link
Copy Markdown
Collaborator

@orizi orizi left a comment

Choose a reason for hiding this comment

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

@orizi reviewed 1 file and all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on eytan-starkware).

@eytan-starkware eytan-starkware added this pull request to the merge queue Apr 23, 2026
Merged via the queue into main with commit 483a832 Apr 23, 2026
54 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.

4 participants