-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Background
A production compiler must not crash or silently miscompile on any valid input. Fuzzing is the most effective way to find these edge cases. Two established tools apply directly:
- LLVM-Stress (
llvm-stress): generates random but syntactically valid.llfiles and has historically found dozens of LLVM optimizer bugs - CSmith: generates random C programs that, when compiled to
.llvia clang, stress the optimizer and codegen with realistic patterns
Goals
Phase 1 — Parser fuzzing
- Feed the output of
llvm-stressdirectly into ourllvm-ir-parser. The parser must either accept valid IR without panicking or return a well-formedParseError. It must never panic or produce undefined behaviour. - Run 10 000+ iterations per CI nightly run.
Phase 2 — Optimizer fuzzing
- Parse each
llvm-stressoutput, run all optimization passes, and compare the printed IR round-trip. Panics and assertion failures are bugs.
Phase 3 — Codegen fuzzing
- For modules that parse and optimise cleanly, run x86-64 codegen. Any panic in the codegen pipeline is a bug.
Phase 4 — Semantic fuzzing (CSmith)
- Compile random C programs with CSmith → clang →
.ll - Feed
.llinto our pipeline → link and run - Compare exit code against clang's native output
- Any mismatch is a miscompilation bug
Acceptance criteria
-
fuzz/crate usingcargo-fuzz(libFuzzer backend) targeting the parser - Nightly GitHub Actions job running
llvm-stress | cargo fuzz run parserfor 5 minutes - CSmith integration script (
scripts/csmith_test.sh) with at least 1 000 random programs - All discovered crashes fixed before closing this issue (track sub-issues)
References
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels