CLIR: Liveness-Driven and Structure-Aware Fuzzing for the Cranelift Compiler
Summary
CLIR, a novel differential testing framework, significantly enhances bug detection and code coverage for the Cranelift compiler backend, which is used for WebAssembly and Rust. It addresses challenges in constructing valid SSA-form IR, generating computationally dense sequences, and facilitating root cause analysis across heterogeneous architectures like x86-64, AArch64, s390x, and RISCV64. CLIR integrates a syntax-preserving hierarchical generation strategy, a liveness-guided instruction refinement mechanism, and a diagnosis-guided cross-architecture adaptation scheme. In a 72-hour evaluation, CLIR detected 24 unique bugs, outperforming cranelift-fuzzgen, wasm-smith, and WASMaker by 8x, 24x, and 8x respectively, while RustSmith found none. It also achieved 68.4% to 79.1% code coverage across architectures, a 1.2x improvement. Of the discovered bugs, 21 were confirmed and 9 fixed.
Key takeaway
For research scientists or compiler engineers testing new compiler backends like Cranelift, you should consider adopting CLIR's structured fuzzing approach. Its ability to generate complex, valid IR and diagnose cross-architecture issues efficiently will uncover more deep-seated bugs than traditional methods. Implement its liveness-guided refinement to ensure your test cases stress critical compiler components effectively.
Key insights
CLIR improves compiler testing by generating complex, valid IR and efficiently diagnosing cross-architecture bugs.
Principles
- SSA validity requires dominator-driven IR generation.
- Computational density maximizes compiler stress.
- Cross-architecture adaptation needs dual-mode testing.
Method
CLIR uses a skeleton generator, an IR initiator with corpus-based snippets and dominator-driven SSA instantiation, and a differential testing module with instrumentation and feedback-driven adaptation.
In practice
- Use corpus-based snippets for realistic IR patterns.
- Employ block parameters to enforce liveness across merges.
- Anchor dependency chains to observable program behaviors.
Topics
- Compiler Fuzzing
- Cranelift Compiler
- Differential Testing
- Intermediate Representation
- SSA Form
- Bug Localization
Code references
- CLIR479/CLIR
- bytecodealliance/wasm-tools
- bytecodealliance/wasmtime
- llvm/llvm-project
- rust-lang/rustc_codegen_cranelift
Best for: AI Scientist, Software Engineer, Research Scientist, Security Engineer
Related on AIssential
Editorial summary, takeaway, and curation by AIssential. Original article published by cs.SE updates on arXiv.org.