Skip to content

Add a hook to run passes over Julia IR - #948

Open
maleadt wants to merge 1 commit into
mainfrom
tb/julia-ir-passes
Open

maleadt wants to merge 1 commit into
mainfrom
tb/julia-ir-passes

Conversation

@maleadt

@maleadt maleadt commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

A new experimental interface function, julia_ir_passes(job), returns passes that run on the optimized IR of every function inferred by GPUInterpreter. They run after Julia's optimizer and IPO analysis, but before Julia computes inlineability and uses the IR for inlining, caching, and code generation: in CC.finish on Julia 1.10–1.12 and CC.finishopt! on 1.13 and later. Each pass is called as pass(interp, opt, ir) and returns the new IR. Back-ends can add passes after GPUCompiler's.

The default is no passes, so this PR does not change behavior.

  • Like the inference parameters, the passes may depend only on the job's target and params because cache_owner uses those to partition inference results.
  • run_julia_ir_passes runs a job's passes independently of the interpreter, allowing other interpreters that compile GPUCompiler jobs, such as Enzyme's, to run them.
  • Before Julia 1.12, the native interpreter re-infers callees whose inferred source Julia discarded, so the passes do not see them. Keep inferred sources on Julia < 1.12 #947 fixes this separately.

@codecov

codecov Bot commented Sep 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.36%. Comparing base (70ad652) to head (1ad3695).
⚠️ Report is 6 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #948      +/-   ##
==========================================
+ Coverage   86.32%   86.36%   +0.04%     
==========================================
  Files          29       29              
  Lines        5756     5766      +10     
==========================================
+ Hits         4969     4980      +11     
+ Misses        787      786       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

The new experimental interface function `julia_ir_passes(job)` returns passes that run on
the Julia IR of every function optimized by `GPUInterpreter`. They run after Julia's
optimizer and IPO analysis, but before the IR is used for inlining, caching, and code
generation (`CC.finish` on Julia 1.10–1.12 and `CC.finishopt!` on 1.13 and later). The
default is no passes. `run_julia_ir_passes` runs a job's passes independently of the
interpreter, allowing other interpreters that compile GPUCompiler jobs to run them.
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