This is an Optimuzz instantiation for LLVM. Optimuzz performs directed fuzzing on LLVM optimizer passes with Alive2 translation validator. Our recent development is available at our website.
We also provide an Optimuzz instantiation with TurboTV for the past bugs of TurboFan.
We provide Dockerfile which installs the system dependencies and configures the environment variables.
docker build -t . optimuzz
docker run -it optimuzz
# Inside the docker
echo $PWD # /home/user/optimuzz
./build.sh
eval $(opam env) # Optimuzz toolchains are installed under the current opam switch
LLVM_PATH
: The LLVM project directory. We use clang/llvm toolchains and libraries to build Optimuzz, Alive2, and other LLVM versions under test.LLVM_BUILDS
: LLVM versions under test will be installed under this directory.
Note that we use LLVM 20.1.1.
The script build.sh
installs the followings:
- the required OPAM packages
- LLVM 20 with the OCaml bindings
- Alive2
- Optimuzz toolchain (
fuzzer
andllmutate
)
We provide following tools to employ Optimuzz.
tools/build.py
: instruments and builds LLVM with a target filetools/harvest.py
collects unit test cases as seeds from LLVM of the targeted committools/targetline.py
asks an LLM to infer the target location from an LLVM committools/fuzz.py
runs our fuzzer.
# Build LLVM with our instrumentation pass
$ tools/build.py commit <commit-sha> <target-file> [--fresh]
$LLVM_BUILDS/llvm-builds/<commit-sha>/build/bin/opt
# Harvest seed files from the LLVM project
# `LLVM_PATH` must be set to extract seeds from the unit test suite
$ tools/harvest.py -o <output-dir>
# Ask LLM to select the target line for a code change of the commit
# You must set `OPENAI_API_KEY` to use OpenAI LLM
$ tools/targetline.py <commit-sha>
{
"target_file": <target-file>,
"target_line": <target-line>,
}
# Fuzz the LLVM project with the provided seed files, target file, and target line
# It should be able to find `fuzzer` and `llmutate` binary in the PATH
# <run-dir> specifies the working directory of the fuzzer
$ tools/fuzz.py <llvm-dir> <seed-dir> <target-file> <target-line> -r <run-dir>
[*] Found target: <target-file>:<line>
[*] Running fuzzer
...
In addition, scripts/repro-turbofan.sh 1195650
performs the reproduction experiment for the TurboFan Bug 1195650.
You can change the number to one of 1195650 1198705 1199345 1200490 1234764 1234770
.
The reproduction detail appears in our paper.