Navigation Menu
Search code, repositories, users, issues, pull requests...
Provide feedback
We read every piece of feedback, and take your input very seriously.
Saved searches
Use saved searches to filter your results more quickly
To see all available qualifiers, see our documentation.
[Reload]()
[Reload]()
[Reload]()
Uh oh!
There was an error while loading. Please reload this page.
[Please reload this page]()
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
[Please reload this page]()
Notifications
You must be signed in to change notification settings
Fork
5.9k
[Fork
5.9k](/login?return_to=%2FJuliaLang%2Fjulia)
Star
48.9k
[Star
48.9k](/login?return_to=%2FJuliaLang%2Fjulia)
WIP/RFC: Unify all our various IR data structures into one#62334
WIP/RFC: Unify all our various IR data structures into one#62334Keno wants to merge 45 commits intoJuliaLang:masterJuliaLang/julia:masterfrom KenoAIStaging:unifiedir-rfcKenoAIStaging/julia:unifiedir-rfcCopy head branch name to clipboard
WIP/RFC: Unify all our various IR data structures into one
Conversation

Keno
commented
Jul 11, 2026
•
edited
Loading
Uh oh!
There was an error while loading. Please reload this page.

Uh oh!
There was an error while loading. Please reload this page.
[Please reload this page]()

Our current IR data structures in Base are about 10 years old at this point. They've held up relatively well, but there are also big problems with. I think the three biggest are that the IR is somewhat hard to use (both for general API design reasons as well as for semantic reasons relating to ownership and invalidation), that it is not extensible to various other use cases that have grown in the ecosystem (leading to people either suffering through hacks or just building their own IR data structures) and really that it was never design to be an externally facing system at all.
This PR tries to fix that by introducing UnifiedIR, a new top-level package alongside Compiler, JuliaSyntax and JuliaLowering (and depended upon by all three) that provides a self-contained, extensible set of IR data structures and operations for use both in Julia base and in the larger ecosystem.
It is a dialect-aware, region-based IR representation (similar to MLIR) but retains a fair bit of the design of the original Julia IR (and JuliaLowering) representation that I thought worked well. It is in particular designed to replace the following existing data structures:
SyntaxTree (from JuliaSyntax)
SyntaxGraph (from JuliaSyntax/Lowering)
CodeInfo (for inference purposes, codegen/interepreter are out of scope for the moment but should be adapted in the future)
IRCode
Various IRs within the ecosystem
To facilitate this, there is a core data structure that provides an efficient representation of the IR along with core utilities. Any particular user of this core data structure can expand it with additional columns (one entry per statement) and there is also a concept of layered views to make it easier to work with the IR in a particular application.
The currently defined layered views are:
An IncrementalCompact like extension that allows fast one-pass replacement passes
An LLVM-like view that maintains ordering through linked lists (thus making complicated CFG transforms a lot easier). To avoid the usual LLVM pitfall of quadratic order maintenance for large functions (which are important to some downstream applications), there's a fancy order maintenance algorithm that claude and I came up with (but still needs validation).
A graph like embedding for use by array compilers (as well as lowering) (Graphs are IR with no control flow dependency)
A tree-like encoding for use by lowering (trees are IR where every statement has exactly one user, except for the root, which has zero).
Major features include first class support for regions (making features like #58532 easy to implement as well as facilitating better integration will MLIR) as well as first class support for dialect extensions.
This PR ports inference, the optimizer and JuliaLowering to the new data structure, but does not yet enable it for bootstrap. That said, I ran about half of the test suite with this version of the compiler and things were working. This should be considered a bit of a preview PR and a basis for discussion. There's many things that still need to be done, but I wanted to put this up so I had something to point to as a basis for discussion.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
[Please reload this page]()
🎉
10 reactions
👀
5 reactions


Add UnifiedIR: one IR substrate as a toplevel package


JuliaSyntax: run on the UnifiedIR substrate


JuliaLowering: add the UnifiedIR direct-lowering backend


Compiler: add Compiler.Unified — inference and optimization natively …


Add UnifiedIR tests, provenance demo, and NEWS entry

gbaraldi
commented
Jul 11, 2026
I guess one thing. Does some form of structured control flow make sense here? Downstream having it has been quite useful. But the passes that structurize it are also quite complete and it's not super useful for lowering to LLVM
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
[Please reload this page]()

Keno
commented
Jul 11, 2026
Yes, the control flow is structured in this representation (with an escape hatch that claude is abusing a bit at the moment, but I'll clean that up).
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
[Please reload this page]()

[WIP/RFC: Add extensible enum types
#62336](/JuliaLang/julia/pull/62336)


Compiler,UnifiedIR: add @code_unified and IR listing display

Keno
commented
Jul 11, 2026
Try at home example:
(Printing subject to improvement)
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
[Please reload this page]()


UnifiedIR: rename the region-result terminator yield to result


Compiler/unified: promote sibling-arm cell stores at if joins


Compiler/unified: island mem2reg (promote_island_cells!)


Compiler/unified: join-point completeness verification harness


UnifiedIR/docs: document §6 join-point completeness


UnifiedIR: make extract indices 1-based


UnifiedIR: dominating-store promotion works inside cfg islands


Compiler/unified: thread island exit values through sealed continues


Compiler/unified: island shapes in the cell fuzzer + threading tests


UnifiedIR/docs: §6 sealed-exit threading


UnifiedIR: innermost-backedge shadowing for promotion hazards


Compiler/unified: relabel order keys after structurize


Compiler/unified: definedness as data, island totality, nested carrie…


Compiler/unified: maybe-undef fuzz shapes, fresh-process acceptance t…


UnifiedIR/docs: §6 definedness as data and the two-category taxonomy


UnifiedIR: print region-owner result types on the closing brace


UnifiedIR/docs: add practical documentation


UnifiedIR: move the cell-promotion mem2reg suite into the substrate
https://claude.ai/code/session_01AecTAWDkYTxeaTQYT8NEhM


UnifiedIR: promote_try_cells! — try-join threading for frame cells
https://claude.ai/code/session_01AecTAWDkYTxeaTQYT8NEhM


JuliaLowering: mem2reg-precise closure-capture analysis (julia#15276)
https://claude.ai/code/session_01AecTAWDkYTxeaTQYT8NEhM


JuliaLowering: typed shared containers for unavoidable closure captures
https://claude.ai/code/session_01AecTAWDkYTxeaTQYT8NEhM


JuliaLowering/UnifiedBackend: closure corpus, capture-zoo demo
https://claude.ai/code/session_01AecTAWDkYTxeaTQYT8NEhM


UnifiedIR/docs: precise capture criterion (§5.7 note) and the worked zoo
https://claude.ai/code/session_01AecTAWDkYTxeaTQYT8NEhM


capture_zoo demo: print the analysis UnifiedIR before/after mem2reg
https://claude.ai/code/session_01AecTAWDkYTxeaTQYT8NEhM


UnifiedIR/docs: why the capture analysis uses a marker call, not clos…
https://claude.ai/code/session_01AecTAWDkYTxeaTQYT8NEhM


UnifiedIR: v1 semantics for the closure op (§5.7 slice)


UnifiedIR: promote_capture_cells! — value-capture promotion in the fi…


JuliaLowering/UnifiedBackend: closure-region lowering path + material…


JuliaLowering: collapse the capture-analysis sidecar onto closure reg…


UnifiedIR/docs: the closure-region slice is implemented


JuliaLowering: untyped shared containers only (remove typed-cell elig…


JuliaLowering: closure-definition sinking (the authorized code motion)
https://claude.ai/code/session_01AbNqJDB4j8dy6GqMRUX6DT


JuliaLowering: merge single-capturer shares into mutable closure structs
https://claude.ai/code/session_01AbNqJDB4j8dy6GqMRUX6DT


JuliaLowering/test: merged-capture representation probes + differentials
https://claude.ai/code/session_01AbNqJDB4j8dy6GqMRUX6DT


UnifiedIR/docs+demo: the mutable-struct share representation
https://claude.ai/code/session_01AbNqJDB4j8dy6GqMRUX6DT


Compiler.Unified: the late pipeline — inference over closure regions
https://claude.ai/code/session_01AbNqJDB4j8dy6GqMRUX6DT


capture_zoo demo: late-pipeline section (typed region IR)
https://claude.ai/code/session_01AbNqJDB4j8dy6GqMRUX6DT


UnifiedIR/docs: the late pipeline — precision without typed containers
https://claude.ai/code/session_01AbNqJDB4j8dy6GqMRUX6DT


capture_zoo demo: lead with abmult, the julia#15276 function
https://claude.ai/code/session_01AbNqJDB4j8dy6GqMRUX6DT

Keno
commented
Jul 16, 2026
As a demonstrative example, this now shares a mem2reg pass between lowering and the optimizer to fix #15276.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
[Please reload this page]()
Learn more about bidirectional Unicode characters
[Show hidden characters]({{ revealButtonHref }})
Reviewers
Assignees
Labels
Projects
Milestone
Development
Successfully merging this pull request may close these issues.
Uh oh!
There was an error while loading. Please reload this page.
[Please reload this page]()
2 participants

