Skip to main content

irsmith

irsmith is an MCP server that lets coding agents debug LLVM, MLIR and CIRCT tools using your own local builds. It runs a compiler command and reads the crash signature, shrinks a crashing input to a small reproducer, and shows which pass changed the IR and how.

Status: early (v0.1). Tested on macOS (Apple silicon) and Linux, with Python 3.11 and 3.13 in CI.

Demo

demo/pr248279.ll is the C test from llvm/llvm-project#248279, an open InstCombine crash that a maintainer confirmed, as clang -O2 hands it to the optimizer. demo/run_demo.py drives irsmith over MCP stdio the way an agent would. One run, against an LLVM build with assertions from 2026-12-03, on an M4 Mac with other jobs running:

$ uv run python demo/run_demo.py --build $IRSMITH_LLVM_BUILD
run               0.1s  opt -passes=default<O2> -disable-output pr248279.ll
                        SIGABRT, assertion at Value.cpp:519, pass instcombine, sig:557d7f91
                        New->getType() == getType() && "replaceAllUses of value with new value of different type!"
reduce           40.0s  154 -> 53 lines (llvm-reduce, 1767 tests), same signature in 3 of 3 checks
diff_passes       0.1s  192 passes finished before the crash, the last was InferAlignmentPass on main
find_duplicates   7.3s  #173177 0.91 closed  [InstCombine] Assertion `New->getType() == getType() && "replaceAllUses...`
                        #248279 0.87 open    [InstCombine] Assertion `New->getType() == getType() && "replaceAllUses...`

Plain llvm-reduce with a grep test reached the same 53 lines in 16.7 s on that machine. The extra time is a Python check per candidate that the crash signature has not changed.

The full transcript, with the reduced file, is in demo/README.md.

Quickstart

claude mcp add irsmith -e IRSMITH_LLVM_BUILD=/path/to/llvm-project/build -- uvx irsmith

This needs uv. Ask the agent to call doctor first. It lists the toolchains and tools it found. For Claude Desktop, Cursor, VS Code, Codex CLI and Windsurf, see docs/clients.md. Without an LLVM build, irsmith uses Homebrew LLVM, with some limits that the same page lists.

To run from source instead:

git clone https://github.com/ambujone/irsmith && cd irsmith && uv sync
export IRSMITH_LLVM_BUILD=/path/to/llvm-project/build
claude mcp add irsmith -- uv --directory "$PWD" run irsmith

Any MCP client that can launch a stdio server works the same way: the command is uv --directory /path/to/irsmith run irsmith.

Tools

Tool What it does
doctor Lists toolchains (version, git revision, assertions on or off), optional tools (alive-tv, cvise, gh) and state dir usage.
run Runs one command under time, memory and output limits. Returns the exit status, peak memory and a crash signature: kind, message, pass, function and top stack frames, with a stable id.
diff_passes Runs a pipeline with opt -print-changed, or with --mlir-print-ir-after-all --mlir-print-ir-after-change for mlir-opt and circt-opt, and returns one diff hunk per pass that changed the IR, within a token budget. If the tool crashes partway, it returns the passes that finished and the crash signature.
reduce Shrinks a crashing .ll, .bc or .mir file with llvm-reduce, or a .mlir file with circt-reduce. Each candidate must crash with the same signature as the original, so the reducer cannot drift to a different bug. Runs as a job.
bisect Finds the commit that introduced a crash, or with find: "fix" the commit that fixed it. At each step it checks out the commit, runs ninja -C <build> <targets> in your build dir and runs the command. A failed build or an unclear result skips the commit. Runs as a job.
find_duplicates Searches GitHub issues for the same crash, given a signature id, a stderr handle or pasted text. Runs up to 3 searches (the assertion text, the top frame, the pass) and ranks the issues by how well they match. Uses gh when it is logged in, else the public API. Results are cached for 24 hours.
job_status, job_cancel Follow or stop a reduce or bisect job. Calls wait at most 55 seconds, because many clients drop longer calls.
read_artifact Reads part of a stored output (stderr, IR dumps, the reduced file) by handle, with offset, limit and grep.

Commands are argv arrays, never shell strings. The first element must be a tool found in a configured toolchain, such as opt or circt-opt. Use {input}, {out} and {tmp} as placeholders.

Configuration

Environment variables: IRSMITH_LLVM_BUILD, IRSMITH_CIRCT_BUILD, IRSMITH_STATE_DIR (default ~/.cache/irsmith), IRSMITH_ALIVE_TV and IRSMITH_CONFIG. Without them, irsmith looks for Homebrew LLVM, /usr/lib/llvm-* and tools on PATH. When gh is not logged in, GITHUB_TOKEN raises the GitHub search rate limit.

The config file is $IRSMITH_CONFIG, else .irsmith.toml in the working directory or a parent, else ~/.config/irsmith/config.toml:

[limits]
timeout_s = 120
memory_mb = 8192
disk_quota_mb = 4096
max_heavy_jobs = 2

[toolchains.llvm]
build_dir = "/path/to/llvm-project/build"

[toolchains.circt]
build_dir = "/path/to/circt/build"

[env]
# extra variables passed to every child

Safety

  • Every child runs in its own process group. Timeouts, cancellation and server shutdown kill the whole tree, including children that called setsid.
  • Memory is limited by sampling the tree's RSS once a second, because macOS ignores memory rlimits.
  • Children get an allowlisted environment (PATH, HOME, LANG, CCACHE_* and your [env] table). Tokens in the server's environment are not passed on.
  • Output streams are capped at 64 MiB each. Each job has a disk quota, and the state dir is capped at 10 GiB, with the oldest finished jobs removed first.
  • If the server dies, the next one kills the process groups it left behind.
  • bisect refuses to start on a tree with uncommitted changes to tracked files, during a bisect, rebase or merge, or with a build that is not Ninja. It checks that the tree is still clean before each checkout and stops if you edited a file. At the end, including on cancel, it puts HEAD back on your branch. Only one bisect runs per repository. If the server dies mid-bisect, the next server restores the branch on startup.
  • GitHub access is read-only. gh runs only auth status and search issues, and HTTP requests are GET requests to the issue search endpoint. gh is the only child that receives GH_TOKEN or GITHUB_TOKEN.

Planned

Not done yet:

  • prove: check a transformation with Alive2. The reduce oracle for miscompiles also needs it.
  • cvise for C and C++ inputs, and .fir input for circt-reduce.
  • Testing on Linux.

Development

uv run pytest

The integration tests use the builds in IRSMITH_LLVM_BUILD and IRSMITH_CIRCT_BUILD and are skipped when those are missing.

License

MIT or Apache-2.0, at your option.

Metadata

Release files for irsmith 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for irsmith 0.2.0
File Size Uploaded Provenance Actions
irsmith-0.2.0.tar.gz 138.2 kB With provenance Details for irsmith-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for irsmith 0.2.0
File Interpreter ABI Platform Actions
irsmith-0.2.0-py3-none-any.whl Python 3 none any Details for irsmith-0.2.0-py3-none-any.whl

Total release size: 200.3 kB

Release files / irsmith-0.2.0.tar.gz

Download URL irsmith-0.2.0.tar.gz
Size 138.2 kB
Tags Source
SHA-256 checksum
How to use checksums
9bc6f1e43e368f4f026a04ebe092663725b3b20f78195cfa82075ee58f295bbd
BLAKE2b-256 checksum
How to use checksums
bc0d31b22ab5fea7a609a534f65b1b512757a430a854dc580e69619b2480f691
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

Release files / irsmith-0.2.0-py3-none-any.whl

Download URL irsmith-0.2.0-py3-none-any.whl
Size 62.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ef60da0d34b040f1aea9c78d27daf8305950c5258f076680594ec1296c0e6e89
BLAKE2b-256 checksum
How to use checksums
f59577dd7548f2bb32bde8e40da0b9931ccb6da1c1d2a2c21edb9dd6c3776908
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

Security for irsmith 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for irsmith-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page