LLVM Opt Benchmark is an LLVM IR dataset for data-driven compiler optimization research. This repository is also used by LLVM developers to evaluate the impact of their patches on real-world applications.
Don't submit PR to add new benchmarks. You can request new open-source C/C++/Rust repos here.
Please cite this work with the following BibTex entry:
@misc{opt-benchmark,
title = {LLVM Opt Benchmark},
url = {https://github.com/dtcxzyw/llvm-opt-benchmark},
author = {Yingwei Zheng},
year = {2023},
}
LLVM developers use this corpus to assess the impact of your patches on real-world applications. If you see a link to this repository in your PR, it means that the target PR demonstrates some performance regressions or improvements caused by your changes. Here are some common questions you may have:
You should be able to reproduce the regression locally in the following steps:
# Apply your patch and rebuild opt.
...
# Download the source IR. Note that you should replace `optimized` with `original`.
wget https://raw.githubusercontent.com/dtcxzyw/llvm-opt-benchmark/refs/heads/main/bench/<program_name>/original/<file_name>.ll
# Run opt to generate the optimized IR.
bin/opt -O3 -disable-loop-unrolling -vectorize-loops=false -vectorize-slp=false -S <file_name>.ll -o opt.ll
Note that you don't need to clone the whole repository.
It is not recommended, as you can use the online service to evaluate your patch on GitHub if you have commit access to the LLVM repository.
You can use python3 ./scripts/gen_optimized.py bench <path-to-opt>
. It will update the optimized IR files. Then you can review the diff with git.
Don't worry about it. If it doesn't affect the compile-time of the parent projects, it is generally acceptable. Otherwise, you may need to adjust the threshold or just handle simple cases.
Don't panic. Perfect is the enemy of good. We never ask the contributors to fix all the regressions before landing their patches.
Please follow the InstCombineContributorGuide to generalize your patch to cover the regression. If it doesn't work, try to find the pattern and file a separate issue. If it is hard to be caught by a separate transformation, try to bail out on the regression case. If we cannot make it better, the patch can still be accepted if the net effect is positive. Ask your reviewer to help you with the decision.
My method is expensive in compile time. But it shows some optimization opportunities. Should I abandon it?
Though we cannot accept the patch, we still encourage you to explore alternative approaches to handle the exposed optimization opportunities. As the distribution of the real-world code is not uniform, in general, a simple heuristic is good enough to cover most of the cases.
We ask the issue reporter and the contributor to provide a motivating example from real-world scenarios. This benchmark only provides additional evidences to support the claim. It is highly recommended to run this benchmark if the real-world use case is missing, or it is found by fuzzers and super-optimizers. See also InstCombineContributorGuide.
The following patches may not be suitable for this benchmark:
- SLPVectorizer/LoopVectorize/LoopUnroll patches. Vectorization and loop unrolling are disabled since the diff is huge and hard to review. The performance is highly dependent on the target machine so the running time may be more representative.
- Sanitizer/Instrumentation/GPU patches. The related patterns are not included in this corpus.
- Patches which handle scalable vectors. This corpus only contains fixed-width vectors (generated from X86 intrinsics).
Not necessarily. The IR diff is only a proxy for the run-time performance. Generally fewer instructions at IR level implies better analysis result and less instructions at run-time. However, it depends on the target micro-architecture and the LLVM CodeGen components. For example, a canonicalization in InstCombine may cause the SelectionDAG to not recognize certain patterns, leading to bad codegen. Please refer to llvm-codegen-benchmark for frequent isel patterns. Anyway, the run-time performance should be the golden metric. The IR diff only helps us to find the root cause of regressions.
In addition, most of IR snippets are not the hot paths in the real-world applications. I choose to keep all the source IR files instead of only keeping the hot spots, as it is useful for monitoring the code size changes, which is also critical for the frontend performance on modern devices. Another reason is that we cannot find the hot paths in large applications like LLVM and verilator-generated simulators. BTW the training data for PGO in some programs is unavailable or highly biased, you know :).
Many IR diffs only change the name of instructions and basic blocks. Previously, I used
llvm-diff
to reduce meaningless changes. However, it is slow and ineffective. Now I use a heuristic name-remapping algorithm to reduce the noise. The algorithm can reduce up to 70% of line changes. However, as it works on textual diff and does not understand the semantics of LLVM IR, it may produce some invalid instructions. Please check the raw diff in the previous commit pre-commit: Update
.
To fit the GitHub's limit of diff rendering, only part of the files are picked to be committed. It is chosen by a heuristic algorithm to improve the diversity of the dataset.
In the diff mode, a summary of the diff is also provided. It contains some key information to allow you to quickly review the changes:
- The number of files changed, lines added and removed (provided by
git diff --shortstat
). It is different from the numbers on the GitHub page, as it counts the statistics before diff reduction. - A summary of the top-10 LLVM statistics changes.
- The number of line changes in each file (provided by
git show <base>..HEAD --numstat --oneline
). You can use this to quickly find the file with the most line additions or deletions (e.g.,cat log | awk '{print $1 - $2, $3}' | sort -n
). - A summary from LLM (powered by Qwen). It provides a high-level overview of the changes. However, it always gives a positive response, so it may not be very useful. You can use it to find the files that are worth reviewing in detail.
From my own experience, the patterns are likely to be similar in the same project. So you can skip the whole project after you review the first few files in the same project. If your patch optimizes the C++/Rust standard library and other widely-used libraries, you can also skip the files with similar bb names in the hunk header (e.g., _ZNSt6vector...
).
Your changes may break existing optimizations. Please reproduce it locally and try to provide a minimal phase-ordering regression test. Then follow the instructions for dealing with regressions above.
Special Acknowledgement: Thank @goldsteinn for providing additional computational resources to meet the growing demand for testing!
-
Fuzzy DAG matching
Please file an issue to provide LLVM IR with a single function. I will add the
grep
label to trigger CI.Example: #1072
-
Middle-end optimization pre-commit testing
Ping me if you want to see what is affected by your PR. It is useful for reviewers to find potential performance regressions and new optimization opportunities.
For convenience, all llvm members are authorized to request pre-commit tests in #1312. Some basic PR editing commands are also supported by leaving a comment starts with
/
:/close
: Close the PR/reopen
: Reopen the PR/add-label labels
: Add labels (separated by comma). Available labels:reviewed
,regression
,crash
,hang
andmiscompilation
./remove-label labels
: Remove labels.
-
Codegen pre-commit testing
See also llvm-codegen-benchmark.
-
Weekly coverage report:
Currently, this repository contains the following libraries/applications:
Name | Language | Stars | Last Updated | Active Files |
---|---|---|---|---|
abc | C | 2025-01-02 | 984 | |
bdwgc | C | 2025-02-01 | 4 | |
box2d | C | 2025-01-27 | 93 | |
brotli | C | 2025-01-31 | 22 | |
c3c | C | 2024-04-16 | 63 | |
chibicc | C | 2020-12-07 | 8 | |
cjson | C | 2024-09-23 | 2 | |
clamav | C | 2025-02-03 | 236 | |
cmake | C | 2025-02-04 | 641 | |
coremark | C | 2023-01-24 | 3 | |
cpython | C | 2025-02-03 | 252 | |
curl | C | 2025-02-03 | 120 | |
darktable | C | 2025-02-03 | 396 | |
ffmpeg | C | 2025-05-19 | 1890 | |
flac | C | 2025-02-03 | 48 | |
freetype | C | 2025-01-28 | 33 | |
git | C | 2025-02-03 | 331 | |
graphviz | C | 2025-02-10 | 249 | |
hdf5 | C | 2025-02-14 | 395 | |
hwloc | C | 2025-02-13 | 48 | |
jemalloc | C | 2025-02-13 | 66 | |
jq | C | 2025-02-16 | 70 | |
kcp | C | 2024-12-01 | 1 | |
lean4 | C | 2025-05-20 | 1047 | |
libdeflate | C | 2025-01-20 | 13 | |
libevent | C | 2025-02-03 | 31 | |
libjpeg-turbo | C | 2024-12-18 | 90 | |
libpng | C | 2025-02-12 | 17 | |
libquic | C | 2016-09-22 | 395 | |
libsodium | C | 2025-01-26 | 114 | |
libuv | C | 2025-02-17 | 35 | |
libwebp | C | 2025-01-30 | 145 | |
linux | C | 2024-02-29 | 1215 | |
lua | C | 2025-01-29 | 32 | |
luajit | C | 2025-01-13 | 71 | |
lvgl | C | 2025-02-17 | 157 | |
lz4 | C | 2025-02-03 | 12 | |
memcached | C | 2025-02-04 | 30 | |
mimalloc | C | 2025-02-17 | 16 | |
miniaudio | C | 2023-11-15 | 1 | |
nanosvg | C | 2024-12-19 | 1 | |
nuklear | C | 2025-02-07 | 1 | |
nuttx | C | 2024-03-04 | 136 | |
ompi | C | 2025-02-14 | 293 | |
oniguruma | C | 2025-02-11 | 19 | |
openblas | C | 2025-02-17 | 350 | |
openssl | C | 2025-02-18 | 1494 | |
osqp | C | 2025-02-13 | 30 | |
php-src | C | 2025-02-17 | 361 | |
portaudio | C | 2025-02-08 | 17 | |
postgres | C | 2025-02-18 | 825 | |
qemu | C | 2025-02-16 | 51 | |
qoi | C | 2025-02-12 | 1 | |
quickjs | C | 2024-07-27 | 8 | |
raylib | C | 2025-02-17 | 7 | |
redis | C | 2025-02-16 | 153 | |
riscv-isa-sim | C | 2025-02-12 | 995 | |
ruby | C | 2025-02-18 | 189 | |
sdl | C | 2025-05-19 | 275 | |
slurm | C | 2025-02-17 | 304 | |
sqlite | C | 2025-02-18 | 3 | |
stb | C | 2024-11-08 | 20 | |
sundials | C | 2024-12-20 | 211 | |
wireshark | C | 2025-02-18 | 1602 | |
wolfssl | C | 2025-02-17 | 40 | |
yyjson | C | 2025-02-12 | 1 | |
zlib | C | 2025-02-13 | 15 | |
zstd | C | 2025-02-13 | 32 | |
abseil-cpp | C++ | 2025-02-15 | 375 | |
annoy | C++ | 2024-07-28 | 1 | |
arrow | C++ | 2025-02-17 | 184 | |
assimp | C++ | 2025-02-17 | 208 | |
boost | C++ | 2024-10-25 | 375 | |
bullet3 | C++ | 2025-01-29 | 218 | |
casadi | C++ | 2025-02-18 | 234 | |
ceres-solver | C++ | 2025-02-17 | 125 | |
cpp-httplib | C++ | 2025-02-17 | 1 | |
crow | C++ | 2025-02-10 | 13 | |
csmith | C++ | 2023-11-02 | 64 | |
cvc5 | C++ | 2025-02-17 | 712 | |
cxxopts | C++ | 2025-01-14 | 1 | |
double-conversion | C++ | 2025-02-14 | 8 | |
draco | C++ | 2025-01-28 | 97 | |
duckdb | C++ | 2025-02-18 | 259 | |
eastl | C++ | 2023-08-16 | 86 | |
entt | C++ | 2025-02-14 | 73 | |
faiss | C++ | 2025-02-14 | 170 | |
flatbuffers | C++ | 2025-02-10 | 35 | |
fmt | C++ | 2025-02-14 | 29 | |
folly | C++ | 2025-02-17 | 272 | |
g2o | C++ | 2025-02-09 | 134 | |
glog | C++ | 2025-02-16 | 20 | |
glslang | C++ | 2024-06-25 | 42 | |
gromacs | C++ | 2025-02-24 | 798 | |
grpc | C++ | 2025-02-24 | 328 | |
gsl | C++ | 2025-02-14 | 13 | |
harfbuzz | C++ | 2025-02-23 | 15 | |
hermes | C++ | 2023-12-15 | 231 | |
hyperscan | C++ | 2023-04-19 | 204 | |
icu | C++ | 2025-02-21 | 452 | |
imgui | C++ | 2025-02-22 | 5 | |
ipopt | C++ | 2025-02-23 | 110 | |
json | C++ | 2025-02-21 | 77 | |
jsonnet | C++ | 2025-02-23 | 17 | |
libcxx | C++ | 2025-05-20 | 86 | |
libigl | C++ | 2025-05-14 | 523 | |
libphonenumber | C++ | 2025-02-13 | 37 | |
libzmq | C++ | 2024-12-30 | 91 | |
lief | C++ | 2025-02-23 | 351 | |
lightgbm | C++ | 2025-02-24 | 34 | |
llama.cpp | C++ | 2025-02-23 | 40 | |
llvm-project | C++ | 2025-02-03 | 2177 | |
lodepng | C++ | 2024-12-28 | 3 | |
luau | C++ | 2025-02-21 | 168 | |
meshlab | C++ | 2024-02-13 | 208 | |
meshoptimizer | C++ | 2025-02-21 | 17 | |
minetest | C++ | 2024-03-26 | 313 | |
mitsuba3 | C++ | 2024-03-22 | 152 | |
mixbox | C++ | 2022-12-16 | 1 | |
mold | C++ | 2025-02-21 | 93 | |
msdfgen | C++ | 2024-01-06 | 16 | |
msgpack-c | C++ | 2025-02-21 | 19 | |
nanobind | C++ | 2025-02-21 | 32 | |
ncnn | C++ | 2025-02-20 | 365 | |
nghttp2 | C++ | 2025-02-18 | 21 | |
ninja | C++ | 2025-02-19 | 59 | |
nix | C++ | 2024-03-06 | 212 | |
node | C++ | 2023-12-17 | 158 | |
nori | C++ | 2023-11-15 | 45 | |
open3d | C++ | 2025-04-03 | 384 | |
open_spiel | C++ | 2024-08-27 | 256 | |
opencc | C++ | 2025-02-12 | 24 | |
opencolorio | C++ | 2025-02-10 | 184 | |
opencv | C++ | 2025-02-25 | 1620 | |
openexr | C++ | 2025-02-18 | 178 | |
openimageio | C++ | 2025-02-25 | 111 | |
openjdk | C++ | 2024-07-16 | 1158 | |
openusd | C++ | 2024-07-24 | 918 | |
openvdb | C++ | 2023-12-06 | 37 | |
ozz-animation | C++ | 2025-01-19 | 40 | |
pbrt-v4 | C++ | 2025-01-30 | 60 | |
pcg-cpp | C++ | 2022-04-08 | 6 | |
pocketpy | C++ | 2024-06-20 | 29 | |
proj | C++ | 2025-02-22 | 243 | |
protobuf | C++ | 2023-12-15 | 125 | |
proxy | C++ | 2024-05-22 | 5 | |
proxygen | C++ | 2023-12-16 | 84 | |
pugixml | C++ | 2025-02-19 | 1 | |
pybind11 | C++ | 2025-02-20 | 1 | |
quantlib | C++ | 2024-09-10 | 882 | |
quest | C++ | 2025-02-08 | 7 | |
re2 | C++ | 2023-12-14 | 17 | |
readerwriterqueue | C++ | 2024-07-09 | 2 | |
recastnavigation | C++ | 2024-01-28 | 47 | |
rocksdb | C++ | 2025-02-26 | 341 | |
sentencepiece | C++ | 2025-02-27 | 51 | |
simdjson | C++ | 2025-02-21 | 1 | |
snappy | C++ | 2024-08-17 | 2 | |
soc-simulator | C++ | 2024-06-25 | 5 | |
spdlog | C++ | 2025-02-11 | 7 | |
stockfish | C++ | 2024-03-03 | 14 | |
taskflow | C++ | 2025-02-21 | 39 | |
tev | C++ | 2024-01-12 | 22 | |
tinygltf | C++ | 2025-01-22 | 1 | |
tinympc | C++ | 2025-02-11 | 8 | |
tinyobjloader | C++ | 2025-01-29 | 1 | |
tinyrenderer | C++ | 2025-02-21 | 4 | |
tomlplusplus | C++ | 2025-02-27 | 1 | |
vcpkg-tool | C++ | 2025-02-27 | 145 | |
velox | C++ | 2023-12-15 | 172 | |
verilator | C++ | 2025-03-02 | 141 | |
wasmedge | C++ | 2024-07-15 | 69 | |
xgboost | C++ | 2025-03-01 | 103 | |
yalantinglibs | C++ | 2023-12-17 | 52 | |
yaml-cpp | C++ | 2025-01-24 | 32 | |
yoga | C++ | 2025-02-27 | 19 | |
yosys | C++ | 2025-03-01 | 310 | |
z3 | C++ | 2025-02-28 | 830 | |
zfp | C++ | 2025-02-12 | 36 | |
zxing-cpp | C++ | 2025-02-19 | 96 | |
actix-web | Rust | 2024-04-15 | 116 | |
anki | Rust | 2024-06-24 | 8 | |
clap | Rust | 2024-03-01 | 19 | |
coreutils | Rust | 2024-04-23 | 722 | |
deku | Rust | 2025-05-16 | 3 | |
delta-rs | Rust | 2024-04-23 | 120 | |
diesel | Rust | 2024-03-01 | 228 | |
egg | Rust | 2024-08-30 | 15 | |
elfshaker | Rust | 2025-05-09 | 16 | |
fish-shell | Rust | 2025-05-19 | 25 | |
foundations | Rust | 2025-05-19 | 15 | |
html5ever | Rust | 2023-09-06 | 43 | |
hyper | Rust | 2024-03-02 | 4 | |
image | Rust | 2024-02-22 | 16 | |
influxdb | Rust | 2024-03-01 | 46 | |
jiff | Rust | 2025-05-18 | 16 | |
json | Rust | 2024-01-11 | 15 | |
just | Rust | 2024-04-01 | 16 | |
log | Rust | 2024-02-29 | 1 | |
logos | Rust | 2024-06-10 | 32 | |
meilisearch | Rust | 2024-06-25 | 44 | |
mini-lsm | Rust | 2024-02-26 | 45 | |
nom | Rust | 2024-04-21 | 9 | |
ockam | Rust | 2024-04-22 | 282 | |
pingora | Rust | 2025-05-09 | 124 | |
polars | Rust | 2025-05-19 | 303 | |
pyo3 | Rust | 2024-06-24 | 31 | |
qdrant | Rust | 2024-03-19 | 44 | |
quiche | Rust | 2025-05-19 | 62 | |
quinn | Rust | 2025-05-20 | 48 | |
raft-rs | Rust | 2025-02-28 | 26 | |
rand | Rust | 2024-02-18 | 9 | |
rayon | Rust | 2024-02-27 | 21 | |
regex | Rust | 2024-01-10 | 46 | |
ring | Rust | 2024-03-03 | 16 | |
ripgrep | Rust | 2024-03-27 | 90 | |
ropey | Rust | 2024-04-08 | 15 | |
ruff | Rust | 2025-05-19 | 421 | |
rust-analyzer | Rust | 2024-04-22 | 471 | |
rust-base64 | Rust | 2024-03-01 | 7 | |
rustfmt | Rust | 2024-03-04 | 16 | |
rustls | Rust | 2024-03-07 | 15 | |
salsa | Rust | 2025-05-19 | 16 | |
serde | Rust | 2024-01-08 | 2 | |
smol | Rust | 2024-03-04 | 16 | |
softposit-rs | Rust | 2022-12-14 | 11 | |
statrs | Rust | 2024-06-24 | 15 | |
syn | Rust | 2024-01-13 | 16 | |
tikv | Rust | 2025-05-20 | 10 | |
tokenizers | Rust | 2024-05-06 | 16 | |
tokio | Rust | 2024-03-04 | 43 | |
tree-sitter | Rust | 2024-03-08 | 86 | |
turborepo | Rust | 2024-10-03 | 60 | |
typst | Rust | 2024-03-25 | 81 | |
unicode-normalization | Rust | 2024-03-03 | 2 | |
uv | Rust | 2025-05-19 | 538 | |
wasmi | Rust | 2025-05-17 | 85 | |
wasmtime | Rust | 2024-04-22 | 319 | |
zed | Rust | 2024-10-04 | 1218 |