optdiff

Crates.iooptdiff
lib.rsoptdiff
version0.8.0
created_at2025-12-20 13:26:41.979306+00
updated_at2025-12-20 13:26:41.979306+00
descriptionA CLI tool that displays diffs of LLVM IR changes between optimization passes
homepage
repositoryhttps://github.com/abrasumente233/optdiff
max_upload_size
id1996511
size248,376
rumi (rumisle)

documentation

README

optdiff

optdiff is a CLI tool that displays differences in LLVM IR between optimization passes. It's a standalone port of the Compiler Explorer optpipeline feature.

For the best experience, install one of these diff visualization tools:

Usage

Consider this example square.c file:

int square(int x) {
    return x * x;
}

You can run optdiff directly with the compiler output:

clang square.c -O2 -mllvm -print-before-all -mllvm -print-after-all -c -o /dev/null 2>&1 | optdiff

Alternatively, you can save the pass dump to a file and process it later:

clang square.c -O2 -mllvm -print-before-all -mllvm -print-after-all -c -o /dev/null &> dump.txt
optdiff dump.txt

By default, optdiff will try to use delta, then riff, then fall back to less as the pager. You can configure the pager:

  • Use the --pager or -p option: optdiff dump.txt -p bat
  • Set the OPTDIFF_PAGER environment variable: OPTDIFF_PAGER=bat optdiff dump.txt

To skip passes that don't modify the IR, use the --skip-unchanged or -s option:

optdiff dump.txt -s

For a complete list of available options:

optdiff --help
Commit count: 0

cargo fmt