Skip to content

jit: add optional LLVM optimization - #6416

Merged
sueszli merged 7 commits into
xdslproject:mainfrom
sueszli:review/jit-optimize
Sep 5, 2026
Merged

sueszli merged 7 commits into
xdslproject:mainfrom
sueszli:review/jit-optimize

Conversation

@sueszli

@sueszli sueszli commented Sep 1, 2026 •

Copy link
Copy Markdown
Collaborator

Adds opt-in host O3 optimization after separating the refactoring requested on PR #6410, comment #3889970708 --- stacked on #6415.

@sueszli sueszli added the JIT Just-In-Time compilation. label Sep 1, 2026
@codecov

codecov Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.95%. Comparing base (53c1b81) to head (4744e6c).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6416      +/-   ##
==========================================
- Coverage   86.95%   86.95%   -0.01%     
==========================================
  Files         439      439              
  Lines       66002    66016      +14     
  Branches     7513     7514       +1     
==========================================
+ Hits        57392    57404      +12     
- Misses       7038     7039       +1     
- Partials     1572     1573       +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.

Comment thread xdsl/jit/llvm/backend.py Outdated
Comment thread xdsl/jit/llvm/backend.py Outdated
"""Pass pipeline applied before resolving ``symbol``."""

optimize: bool
"""Run host O3 optimization."""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not very clued up on what's happening here, but why have a boolean for O3 optimisation instead of a level allowing you to choose the optimisation lever?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This is just a very opinionated way to just apply ✨ all the optimizations ✨.

Would it be better to make this more configurable or update the comment?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This could also be a seperate follow up PR

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's just make this match the llvm API, if they provide integer levels then it feels like we should here also.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Actually probably integer levels or None if we want to skip optimisations.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Donzo 🫡
Did i get this right?

Comment thread xdsl/jit/llvm/backend.py Outdated
@superlopuh

Copy link
Copy Markdown
Member

Am I right in understanding that this could now target main?

@sueszli
sueszli changed the base branch from sueszli/jit-native-target-base to main September 3, 2026 15:17
@sueszli

sueszli commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator Author

Whoops 😅 Yes yes

@sueszli
sueszli force-pushed the review/jit-optimize branch from fab5be3 to 8fdca4d Compare September 3, 2026 15:21
Comment thread xdsl/jit/llvm/backend.py Outdated
Comment thread xdsl/jit/llvm/backend.py Outdated
opt_level was optional, and None skipped the IR pipeline while code generation
still ran at level 2. Make it a plain int defaulting to 2, so both agree, and
check its range when the backend is constructed rather than when it runs.
opt_level took any int and rejected out of range values at construction, which
duplicates a constraint llvmlite already owns. Make it a Literal instead, so
pyright rejects a bad level at the call site and the runtime check can go.
Comment thread xdsl/jit/llvm/backend.py
),
),
*,
opt_level: Literal[0, 1, 2, 3] = 2,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm confused, does this change what is happening? previously, we were not passing anything to opt, now we pass 2, is that guaranteed to be the default value for the opt argument to target_machine?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Previously, passing None was silly, and the 2 flag is the llvmlite default.

This should be the expected behavior now.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for paying close attention

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Likewise, thanks for this improvement :)

@sueszli
sueszli merged commit 97d0b5a into xdslproject:main Sep 5, 2026
25 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

JIT Just-In-Time compilation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants