Skip to content

Improve compiler driver tool stages [1/3] - #3402

Merged
dime10 merged 8 commits into
mainfrom
improve-compiler-driver-stages
Oct 28, 2026
Merged

dime10 merged 8 commits into
mainfrom
improve-compiler-driver-stages

Conversation

@dime10

@dime10 dime10 commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

This is PR 1 of 3 to improve and fix the Catalyst CLI interface pertaining to stage selection and output production, which is inflexible and even non-sensical at times (e.g., generating object code via the cli requires specifying an output file for the llvm ir via -o, which should not only be unrelated, but also isn't even written to unless keep-intermediate is also specified).

In this PR, the LLVM stages are split up into separate llvm-opt and llc tools, responsible for running our LLVM IR pass pipeline and LLVM's object code generation pipeline, respectively. Additionally, the --tool is extended to accept aggregate "tools" as well in order to easily run compilation to a certain point without requiring separate invocations.


assisted by Astra

The separate stages now allow invoking the Catalyst CLI with a precise
target:
- starting MLIR (implicitly since it's input)
- final MLIR
- starting LLVM
- final LLVM
- object code
@codecov

codecov Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.22%. Comparing base (db4b6b5) to head (675b59a).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3402      +/-   ##
==========================================
- Coverage   96.23%   96.22%   -0.01%     
==========================================
  Files         177      177              
  Lines       21638    21639       +1     
  Branches     2169     2168       -1     
==========================================
- Hits        20824    20823       -1     
- Misses        629      630       +1     
- Partials      185      186       +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.

@mehrdad2m mehrdad2m left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @dime10. It looks great!

Comment thread doc/releases/changelog-dev.md Outdated
Comment thread frontend/test/lit/test_opt.py
dime10 and others added 3 commits October 28, 2026 13:23
Co-authored-by: Mehrdad Malek <39844030+mehrdad2m@users.noreply.github.com>
@dime10
dime10 merged commit a1185b7 into main Oct 28, 2026
38 checks passed
@dime10
dime10 deleted the improve-compiler-driver-stages branch October 28, 2026 17:44
dime10 added a commit that referenced this pull request Oct 28, 2026
This is PR 3 of 3 to improve and fix the Catalyst CLI interface
pertaining to stage selection and output production. It also builds on
PR #3391 to provide an accessible way of running compilation to a
particular stage for testing and benchmarking.

In this PR, the `target` selection feature for AOT compilation is fixed
to properly select the appropriate stage, even when that stage is not
controlled from the frontend (like jaxpr/mlir generation or linking is).
In particular:
- `target="llvmir"` now correctly stops after the translation step from
MLIR to LLVM IR, which previously wasn't possible (see follow up
recorded here:
#3391 (comment))
- new targets "llvmir_opt" and "object" further provide access to the
internal stages of the catalyst compiler (exposed in #3402 and #3403)

Additional, some cleanup on previous changes in the series is performed:
- The obsolete second "llvm_ir" return value from internal compile
functions is removed, such that there is always exactly one result.
- In order to prevent invalid state from being returned by the `.llvmir`
accessor, the cache attribute `.llvm_ir` is removed from the class.
While this means the textual llvm ir needs to be regenerated upon each
inspection, this is inline with the other IR accessors (`.mlir` and
`.mlir_opt`) and leaves the door open to overhaul these together in
future work.

---

assisted by Astra
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.

2 participants