mcpbeat Sign in

Dump Intermediate Ir Agent Skill

>- Augments a `bazel run` CLI command for `heir-opt` with additional flags that dump the IR before each compiler pass, allowing the agent to inspect intermediate IR during compilation, identify a particular pass at which the pipeline fails, or extract the corresponding IR input to a particular pass for further debugging.

2k tokens
context cost
the whole folder, loaded on every use
1
files
instructions only
0
copies elsewhere
how many repositories repackaged it
754
stars on the repo
on the repository, not the skill itself

Install

one command, takes just this skill from the repository
npx skills add https://github.com/google/heir --skill dump-intermediate-ir

The instruction itself

7 sections, as written by the author

Dump intermediate IR during compilation

Overview

This skill guides the agent in adding flags to the heir-opt tool to dump the

compiled IR after each compiler pass to a series of files. These files can then

be inspected to identify the failing pass as well as the IR input to the failing

pass.

Usage

Converting a bazel run command

To convert a bazel run command, add the flags --mlir-print-ir-before-all and

--mlir-print-ir-tree-dir=<PATH>, where <PATH> is a path to a temporary

directory.

For example, given the following input command (which can be produced by the

lit-to-bazel skill),

bazel run //tools:heir-opt -- --mlir-to-ckks='ciphertext-degree=8' --scheme-to-openfhe='entry-function=dot_product' /path/to/file

The agent should produce the following (again where <PATH> is chosen

appropriately)

bazel run //tools:heir-opt -- --mlir-to-ckks='ciphertext-degree=8' --scheme-to-openfhe='entry-function=dot_product' --mlir-print-ir-before-all --mlir-print-ir-tree-dir=<PATH> /path/to/file

Tree structure

--mlir-print-ir-tree-dir nests the dumped IR in a tree structure that matches

the nesting structure of the pass pipeline. In particular, by default all passes

will be nested under a builtin_module_no-symbol-name/ folder, and any passes

in the pipeline that are anchored on nested operations like func.func will be

placed in subdirectories based on the name, such as

func_func_matvec__decrypt__result0 for a pass anchored on func.func when the

IR contains a function called matvec__decrypt__result0.

For example, if the flag --mlir-print-ir-tree-dir=/tmp/mlir is used, then the

dumped files might look like:

/tmp/mlir/
└── builtin_module_no-symbol-name
    ├── 0_annotate-module.mlir
    ├── 10_compare-to-sign-rewrite.mlir
    ├── 11_canonicalize.mlir
    ├── 12_cse.mlir
    ├── 13_apply-folders.mlir
    ├── 14_canonicalize.mlir
    ├── 15_insert-rotate.mlir
    ├── 16_cse.mlir
    ├── 17_canonicalize.mlir
    ├── 18_cse.mlir
    ├── 19_collapse-insertion-chains.mlir
    ├── 1_debug-validate-names.mlir
    ├── 20_sccp.mlir
    ├── 21_canonicalize.mlir
    ...
    ├── func_func__assign_layout_9911323688340753831
    │   ├── 47_0_affine-expand-index-ops.mlir
    │   ├── 47_1_affine-simplify-structures.mlir
    │   ├── 47_2_affine-loop-normalize.mlir
    │   └── 47_3_forward-insert-slice-to-extract-slice.mlir
    ├── func_func_matvec
    │   ├── 47_0_affine-expand-index-ops.mlir
    │   ├── 47_1_affine-simplify-structures.mlir
    │   ├── 47_2_affine-loop-normalize.mlir
    │   └── 47_3_forward-insert-slice-to-extract-slice.mlir
    ├── func_func_matvec__decrypt__result0
    │   ├── 47_0_affine-expand-index-ops.mlir
    │   ├── 47_1_affine-simplify-structures.mlir
    │   ├── 47_2_affine-loop-normalize.mlir
    │   └── 47_3_forward-insert-slice-to-extract-slice.mlir
    └── func_func_matvec__encrypt__arg0
        ├── 47_0_affine-expand-index-ops.mlir
        ├── 47_1_affine-simplify-structures.mlir
        ├── 47_2_affine-loop-normalize.mlir
        └── 47_3_forward-insert-slice-to-extract-slice.mlir

Dumped file contents

At the top of each file, a comment is printed indicating how the file was

generated, containing e.g., IR Dump Before CSEPass (cse). This will say

whether the IR was dumped before or after a pass, as well as whether (in the

case of --mlir-print-ir-after-failure) the pass failed.

Below the comment, the MLIR is printed in textual format.

Gotchas

  • Stale files: --mlir-print-ir-tree-dir does not delete existing files, so

if the command is re-run, be sure to remove the existing temporary files

first.

  • Dump before vs after: --mlir-print-ir-before-all prints the IR before a

pass runs, which is required to extract the IR if a pass has a hard error like

a segfault. To dump the IR *after* each pass, use --mlir-print-ir-after-all.

  • Dumping after failure: For some errors without stack traces (like a

dialect conversion failure where the compiler fails gracefully), you can use

--mlir-print-ir-after-failure to dump the IR at failure time, which can

provide additional debugging information. One notable example is when dialect

conversion fails, the IR dumped by --mlir-print-ir-after-failure includes

the partially-converted IR including any unrealized_conversion_cast ops that

failed to be removed.

  • Dumping after change: The number of files can be reduced by using

--mlir-print-ir-after-change, which only prints the IR if the compiler pass

changed it. There is no "before change" analogue.

  • Dumping after change: The number of files can be reduced by using

--mlir-print-ir-before=<pass_name>, which only prints the IR before the

target pass. Since a pass can be run multiple times in a pipeline, this may

still produce many files if, for example, the pass is a common one like cse.

Copy this checklist and track progress:

- [ ] Step 1: Identify the command to convert, perhaps with `lit-to-bazel`
- [ ] Step 2: Add the relevant flags, defaulting to `--mlir-print-ir-before-all` and `--mlir-print-ir-tree-dir` if there is no specific reason to use the more specific flags.
- [ ] Step 3: Inspect the generated command and run it.
- [ ] Step 4: Inspect the dumped files for information.

<!-- mdformat global-off -->

Other skills for the same job

different authors, same section of the catalogue
MCP Builder
by anthropics
vendor ×13

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

30k tokens scripts
Changelog Generator
by frostant
×9

Automatically creates user-facing changelogs from git commits by analyzing commit history, categorizing changes, and transforming technical commits into clear, customer-friendly release notes. Turns hours of manual changelog writing into minutes of automated generation.

774 tokens
Finishing A Development Branch
by ZhanlinCui
×7

Use when implementation is complete, all tests pass, and you need to decide how to integrate the work - guides completion of development work by presenting structured options for merge, PR, or cleanup

1k tokens
MCP Builder
by JayZeeDesign
×7

Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK).

37k tokens scripts
Vercel React Native Skills
by vercel-labs
vendor ×6

React Native and Expo best practices for building performant mobile apps. Use when building React Native components, optimizing list performance, implementing animations, or working with native modules. Triggers on tasks involving React Native, Expo, mobile performance, or native platform APIs.

39k tokens
Vercel React Best Practices
by ratacat
×5

React and Next.js performance optimization guidelines from Vercel Engineering. This skill should be used when writing, reviewing, or refactoring React/Next.js code to ensure optimal performance patterns. Triggers on tasks involving React components, Next.js pages, data fetching, bundle optimization, or performance improvements.

34k tokens
Next Best Practices
by vercel-labs
vendor ×4

Next.js best practices - file conventions, RSC boundaries, data patterns, async APIs, metadata, error handling, route handlers, image/font optimization, bundling

20k tokens
Using Git Worktrees
by ZhanlinCui
×4

Use when starting feature work that needs isolation from current workspace or before executing implementation plans - creates isolated git worktrees with smart directory selection and safety verification

1k tokens

How to use it

Copy the folder

Take google/dump-intermediate-ir from the repository into ~/.claude/skills for personal use, or into .claude/skills inside a project.

Check the name does not clash

The agent identifies a skill by the name field in its header. Two skills with the same name cannot sit side by side — one of them will be ignored.