codegen: Add llvm_options parameter to code_llvm for pass instrumentation#60698
Open
codegen: Add llvm_options parameter to code_llvm for pass instrumentation#60698
Conversation
9be33d6 to
e363be3
Compare
Member
|
This is amazing! Thank you so much! |
Member
|
The only UI question IMO is whether we want the string interface or to use a kwarg interface (e.g. |
Member
Author
|
I initially had something like that but to me it felt weird. This is very much a LLVM api and I think users of this are probably familiar with that syntax. (it's also much simpler to plumb through) |
vtjnash
reviewed
Jan 15, 2026
vtjnash
reviewed
Jan 15, 2026
6e72b9d to
12d1b7e
Compare
vchuravy
reviewed
Jan 15, 2026
vtjnash
reviewed
Jan 15, 2026
vtjnash
reviewed
Jan 15, 2026
7678a81 to
7ddc6e3
Compare
vtjnash
reviewed
Jan 16, 2026
vtjnash
reviewed
Jan 16, 2026
2bc0119 to
d083a17
Compare
3d99c05 to
4d73f42
Compare
vtjnash
reviewed
Feb 7, 2026
99b0868 to
cabf404
Compare
…tion Add an `llvm_options` keyword argument to `code_llvm` that accepts LLVM-style option strings for controlling pass instrumentation output. This enables printing IR before/after optimization passes, filtering by pass name and function name, and printing at module scope. Supported options: -print-before-all / -print-after-all -print-before=<pass> / -print-after=<pass> (comma-separated or repeated) -filter-print-funcs=<name> (comma-separated or repeated) -print-module-scope Options are parsed using LLVM's TokenizeGNUCommandLine. Pass output is captured and prepended to the final IR output. The filter-print-funcs option supports comma-separated lists matching LLVM's CommaSeparateAndAddOccurrence behavior, and properly suppresses output for non-Function IR when a filter is set. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
56c1479 to
1a5b5c0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add the ability to pass LLVM pass manager options directly to code_llvm() for debugging and analysis purposes. This allows users to inspect IR at various stages of the optimization pipeline without needing to set environment variables.
Supported options include:
-print-after-all: Print IR after each pass-print-before-all: Print IR before each pass-print-after=<passname>: Print IR after a specific pass-print-before=<passname>: Print IR before a specific pass-print-module-scope: Print entire module instead of just the function-filter-print-funcs=<name>: Filter output to specific functionsExample usage:
code_llvm(+, (Int, Int); llvm_options="-print-after=loop-vectorize")