| Crates.io | optdiff |
| lib.rs | optdiff |
| version | 0.8.0 |
| created_at | 2025-12-20 13:26:41.979306+00 |
| updated_at | 2025-12-20 13:26:41.979306+00 |
| description | A CLI tool that displays diffs of LLVM IR changes between optimization passes |
| homepage | |
| repository | https://github.com/abrasumente233/optdiff |
| max_upload_size | |
| id | 1996511 |
| size | 248,376 |
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:
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:
--pager or -p option: optdiff dump.txt -p batOPTDIFF_PAGER environment variable: OPTDIFF_PAGER=bat optdiff dump.txtTo 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