Skip to content

Navigation Menu

Sign in

Search code, repositories, users, issues, pull requests...

Search syntax tips

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.

documentation

Sign in

Sign up

[Reload]()

[Reload]()

[Reload]()

Uh oh!

There was an error while loading. Please reload this page.

[Please reload this page]()

JuliaLang

julia

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

Notifications

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

Keno

JuliaLang:master

KenoAIStaging:unifiedir-rfc

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

Keno

JuliaLang:master

KenoAIStaging:unifiedir-rfc

Conversation

@Keno

Keno

commented

Jul 11, 2026

edited

Loading

Uh oh!

There was an error while loading. Please reload this page.

@Keno

Keno

Jul 11, 2026

Uh oh!

There was an error while loading. Please reload this page.

[Please reload this page]()

il_1588xN 2422929160_bfaa-1-600x596

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.

#58532

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

Keno

July 11, 2026 00:55

@Keno

@claude

Add UnifiedIR: one IR substrate as a toplevel package

4a4f1ff

@Keno

@claude

JuliaSyntax: run on the UnifiedIR substrate

7bd2880

@stm

@Keno

@claude

JuliaLowering: add the UnifiedIR direct-lowering backend

277f17b

@Keno

@claude

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

a6fccd3

@Keno

@claude

Add UnifiedIR tests, provenance demo, and NEWS entry

101fbf6

@gbaraldi

gbaraldi

commented

Jul 11, 2026

gbaraldi

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

Keno

commented

Jul 11, 2026

Keno

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]()

@Keno

Keno

Jul 11, 2026

[WIP/RFC: Add extensible enum types

#62336](/JuliaLang/julia/pull/62336)

@Keno

@claude

Compiler,UnifiedIR: add @code_unified and IR listing display

440869f

@Keno

Keno

commented

Jul 11, 2026

Keno

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]()

Keno

July 11, 2026 03:36

@Keno

@claude

UnifiedIR: rename the region-result terminator yield to result

4629fc9

@Keno

@claude

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

501fecb

@Keno

@claude

Compiler/unified: island mem2reg (promote_island_cells!)

d067c50

@Keno

@claude

Compiler/unified: join-point completeness verification harness

cd9ef3b

@Keno

@claude

UnifiedIR/docs: document §6 join-point completeness

db957be

@Keno

@claude

UnifiedIR: make extract indices 1-based

1b5f196

@Keno

@claude

UnifiedIR: dominating-store promotion works inside cfg islands

4610975

@Keno

@claude

Compiler/unified: thread island exit values through sealed continues

779a3dd

@Keno

@claude

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

01ed841

@Keno

@claude

UnifiedIR/docs: §6 sealed-exit threading

4135488

@Keno

@claude

UnifiedIR: innermost-backedge shadowing for promotion hazards

f955bff

@Keno

@claude

Compiler/unified: relabel order keys after structurize

525ac54

@Keno

@claude

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

678f6aa

@Keno

@claude

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

c443988

@Keno

@claude

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

f7c9596

@Keno

@claude

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

2c77248

@Keno

@claude

UnifiedIR/docs: add practical documentation

60b6eca

@Keno

@claude

UnifiedIR: move the cell-promotion mem2reg suite into the substrate

42bae1b

https://claude.ai/code/session_01AecTAWDkYTxeaTQYT8NEhM

@Keno

@claude

UnifiedIR: promote_try_cells! — try-join threading for frame cells

be75dce

https://claude.ai/code/session_01AecTAWDkYTxeaTQYT8NEhM

@Keno

@claude

JuliaLowering: mem2reg-precise closure-capture analysis (julia#15276)

469e7c6

https://claude.ai/code/session_01AecTAWDkYTxeaTQYT8NEhM

Keno

July 12, 2026 10:40

@Keno

@claude

JuliaLowering: typed shared containers for unavoidable closure captures

349517b

https://claude.ai/code/session_01AecTAWDkYTxeaTQYT8NEhM

@Keno

@claude

JuliaLowering/UnifiedBackend: closure corpus, capture-zoo demo

50eeb45

https://claude.ai/code/session_01AecTAWDkYTxeaTQYT8NEhM

@Keno

@claude

UnifiedIR/docs: precise capture criterion (§5.7 note) and the worked zoo

ba41f36

https://claude.ai/code/session_01AecTAWDkYTxeaTQYT8NEhM

@Keno

@claude

capture_zoo demo: print the analysis UnifiedIR before/after mem2reg

30478e2

https://claude.ai/code/session_01AecTAWDkYTxeaTQYT8NEhM

@Keno

@claude

UnifiedIR/docs: why the capture analysis uses a marker call, not clos…

1ca5d75

https://claude.ai/code/session_01AecTAWDkYTxeaTQYT8NEhM

@Keno

@claude

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

dc9a117

@Keno

@claude

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

6554a71

@Keno

@claude

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

f299976

@Keno

@claude

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

fad0ff5

@Keno

@claude

UnifiedIR/docs: the closure-region slice is implemented

8386bbb

@Keno

@claude

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

9a232fc

@Keno

@claude

JuliaLowering: closure-definition sinking (the authorized code motion)

26f5af3

https://claude.ai/code/session_01AbNqJDB4j8dy6GqMRUX6DT

@Keno

@claude

JuliaLowering: merge single-capturer shares into mutable closure structs

4070f0c

https://claude.ai/code/session_01AbNqJDB4j8dy6GqMRUX6DT

@Keno

@claude

JuliaLowering/test: merged-capture representation probes + differentials

c4de6d8

@isdefined

https://claude.ai/code/session_01AbNqJDB4j8dy6GqMRUX6DT

@Keno

@claude

UnifiedIR/docs+demo: the mutable-struct share representation

439a6a1

https://claude.ai/code/session_01AbNqJDB4j8dy6GqMRUX6DT

@Keno

@claude

Compiler.Unified: the late pipeline — inference over closure regions

332f6d8

https://claude.ai/code/session_01AbNqJDB4j8dy6GqMRUX6DT

@Keno

@claude

capture_zoo demo: late-pipeline section (typed region IR)

dd3883f

https://claude.ai/code/session_01AbNqJDB4j8dy6GqMRUX6DT

@Keno

@claude

UnifiedIR/docs: the late pipeline — precision without typed containers

507049d

https://claude.ai/code/session_01AbNqJDB4j8dy6GqMRUX6DT

@Keno

@claude

capture_zoo demo: lead with abmult, the julia#15276 function

88cba96

https://claude.ai/code/session_01AbNqJDB4j8dy6GqMRUX6DT

@Keno

Keno

commented

Jul 16, 2026

Keno

Jul 16, 2026

As a demonstrative example, this now shares a mem2reg pass between lowering and the optimizer to fix #15276.

#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 }})

Sign up for free

Sign in to comment

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

@Keno

@gbaraldi