Skip to content

mega mir redo#1404

Open
sbillig wants to merge 3 commits intoargotorg:masterfrom
sbillig:quagmir
Open

mega mir redo#1404
sbillig wants to merge 3 commits intoargotorg:masterfrom
sbillig:quagmir

Conversation

@sbillig
Copy link
Copy Markdown
Collaborator

@sbillig sbillig commented Apr 22, 2026

Note: I haven't fully vetted this on the external test cases since rebasing, will do so in the morning.

The big change here is to split MIR into phases. SMIR -> NSMIR -> MIR -> Sonatina/Yul

SMIR ("semantic mir") - this is basically hir in cfg form. Used for const time function evaluation (and thus needs to live in the hir crate to avoid a dependency cycle between hir and mir). This allows us to cleanly expand const fn capabilities, and replaces the previous ugly hir-based implementation.
NSMIR (normalized) - includes concrete borrowing and place/origin information. Used for borrow checking and other diagnostics.
MIR - low-level, but backend neutral representation that's lowered into sonatina/yul. Includes concrete layouts, const/code regions, etc

(Aside: SMIR and NSMIR could maybe be collapsed together. NSMIR just derives a bunch of information that isn't relevant for ctfe)

This fixes a lot of tricky bugs we had previously due to sidecar info alongside the insufficient representation, and information being deduced/inferred in late stages because it wasn't propagated forward by earlier stages.

Unfortunately basically every snapshot has been updated. Name mangling that was previously done in the old MIR is now deferred to codegen, and yul currently uses a simple incremented suffix for conflicting names, which should be changed.

(Aside: I think we should consider replacing the big codegen snapshots with small targeted snapshots.)

TODO, here or in quick follow-up prs

  • remove diagnostic blocks preventing const fn functionality that's already supported (mut, while, ..?)
  • add uninitialized var analysis. most of the machinery for this is in place.
  • port over previous naming scheme, or make a new one
  • newsfragment

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: 17ac59eacb

ℹ️ 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/fe/src/test/mod.rs
@sbillig
Copy link
Copy Markdown
Collaborator Author

sbillig commented Apr 22, 2026

@codex review

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: f3afd41a74

ℹ️ 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/driver/src/db.rs
Comment on lines +81 to +84
ingot
.all_modules(self)
.iter()
.flat_map(|top_mod| self.mir_diagnostics_for_top_mod(*top_mod, mode))
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid re-running ingot MIR diagnostics per top module

Iterating ingot.all_modules(self) here and calling mir_diagnostics_for_top_mod on each module can emit the same semantic-borrow diagnostic multiple times for the same code, because the per-module collector walks each module’s full item tree (including nested items) rather than only file-local items. In multi-file ingots this causes duplicated diagnostics to flow to callers like the language server (which sorts but does not deduplicate), and also does redundant analysis work. Running once from a single root module (or deduplicating before return) avoids this.

Useful? React with 👍 / 👎.

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