Papers
Topics
Authors
Recent
Search
2000 character limit reached

CLIR: Liveness-Driven and Structure-Aware Fuzzing for the Cranelift Compiler

Published 25 Jun 2026 in cs.SE | (2606.26977v1)

Abstract: Modern compilers are complex software systems that must correctly translate high-level programming languages into machine code across multiple architectures. Cranelift, a fast and modern compiler backend originally developed for WebAssembly and recently adopted as an experimental backend for Rust, has gained increasing importance due to its superior compilation speed compared to LLVM and comprehensive multi-architecture support, including x86-64, AArch64, s390x, and RISCV64. However, despite decades of development in compiler testing, testing Cranelift still presents unique challenges, including (1) constructing valid IR under the strict enforcement of SSA form, (2) generating sequences with sufficient computational density to stress backend components, and (3) balancing broad backend coverage with efficient root cause analysis across heterogeneous architectures. To address these challenges, we propose CLIR, a differential testing framework that integrates a syntax-preserving hierarchical generation strategy to guarantee SSA validity, a liveness-guided instruction refinement mechanism to maximize computational density, and a diagnosis-guided cross-architecture adaptation scheme to facilitate efficient root cause analysis across heterogeneous backends. Our comprehensive evaluation demonstrates that CLIR significantly outperforms existing state-of-the-art baselines, detecting 8x, 24x, and 8x more unique bugs than cranelift-fuzzgen, wasm-smith, and WASMaker, respectively, while RustSmith uncovered no bugs. Consequently, within 72 hours of testing, CLIR discovered 24 bugs spanning all target architectures, with 21 confirmed and 9 fixed.

Summary

  • The paper introduces CLIR, a differential testing framework that enhances Cranelift testing using structure-aware IR generation and liveness-guided refinement.
  • CLIR employs corpus-driven hierarchical SSA generation and prioritized operand selection to produce IR with high computational density and deep dependency chains.
  • Empirical evaluation shows CLIR outperforms baselines, discovering 24 unique bugs and achieving superior code coverage across multiple architectures.

CLIR: A Liveness-Driven, Structure-Aware Fuzzing Framework for Comprehensive Cranelift Compiler Testing

Introduction and Motivation

Cranelift is a fast, safe compiler backend with wide adoption for WebAssembly and as a Rust backend, with multi-architecture support (x86-64, AArch64, s390x, RISCV64). Despite extensive development in compiler testing, three core obstacles hamper robust backend validation: (1) generation of syntactically valid IR under strict SSA form, (2) creation of IR sequences with sufficient computational density to test backend components, and (3) efficient root cause analysis across heterogeneous architectures.

The "CLIR: Liveness-Driven and Structure-Aware Fuzzing for the Cranelift Compiler" paper introduces CLIR, a differential testing framework that systematically addresses these challenges in Cranelift testing (2606.26977). CLIR integrates SSA-valid, hierarchical IR generation, liveness-guided instruction refinement to maximize dependency density, and diagnosis-guided cross-architecture adaptation for failure clustering and root cause localization.

Syntactically Valid and Structure-Aware IR Generation

Cranelift IR uses a strict SSA form with block parameters instead of phi nodes Figure 1. The key challenge is constructing IR that upholds dominance and type constraints under complex control flows.

Figure 1

Figure 1: A C code snippet and the corresponding Cranelift IR program.

CLIR employs a corpus-driven, syntax-preserving hierarchical SSA generation strategy. Real-world Rust and WebAssembly programs are compiled to Cranelift IR, and their basic blocks are extracted. This corpus forms the foundation for assembling complex function skeletons and CFGs using atomic structures—sequential, if-else, loop, and switch-case Figure 2. Block parameters are constructed using a dominator-driven algorithm to guarantee SSA compliance, as illustrated in Figure 3.

Figure 2

Figure 2

Figure 2: Atomic structures representing the controllable building blocks of intra-procedural CFG construction.

Figure 3

Figure 3: Constructing block parameters for control flow merge points.

This top-down assembly of IR, enforcing single-entry-single-exit at all levels, allows deep nesting of control constructs, producing IR with high cyclomatic complexity and dominator tree depth, tailored for exhaustive backend path exploration.

Liveness-Guided Instruction Refinement

Structural validity alone is insufficient for backend bug discovery; computational complexity and persistent data dependencies are essential to prevent optimization passes from trivializing test cases. CLIR introduces several liveness-driven mechanisms:

  • Control Flow Merge Liveness: At merge points, block parameters are type-matched to the live-outs of all predecessors, forcing transitive data dependencies across regions.
  • Priority-Based Operand Selection: When filling instruction operands, preference is given to recent definitions, block parameters, and function call results, promoting long def-use chains within and across blocks.
  • Sink-Anchoring: At function exits, all leaf (live but unused) variables are forcefully routed to return values or memory stores, ensuring upstream computations cannot be dead-code eliminated.

This systematic refinement yields IR with significant instruction diversity and deep, observable dependency chains.

Diagnosis-Guided Cross-Architecture Adaptation

Differential testing on heterogeneous backends faces two substantial bottlenecks: feature-subset compatibility for test validity and high-volume failure noise from duplicated root causes. CLIR utilizes a dual-mode adaptation strategy Figure 4:

Figure 4

Figure 4: The workflow of the diagnosis-guided cross-architecture adaptation strategy.

  • Compatible Mode guarantees intersection-set IR features across backends.
  • Target-Specific Mode enables full exploitation of backend-unique features.

Hierarchical failure diagnosis is achieved using signature-guided clustering (based on crash type and error patterns) and static instrumentation. CLIR progressively inserts execution barriers (at function/block boundaries) to localize bugs, and employs SSA-preserving instruction substitution for instruction-level fault isolation. Feedback-driven profile masking iteratively disables known faulty patterns, uncovering otherwise occluded bugs.

Empirical Evaluation

Effectiveness in Bug Discovery and Coverage

CLIR outperforms all baselines (cranelift-fuzzgen, RustSmith, wasm-smith, WASMaker) by a wide margin, as summarized below:

Tool Unique Bugs Found Avg. Code Coverage (%)
CLIR 24 75.1 ± 1.7
cranelift-fuzzgen 3 65.1 ± 1.8
wasm-smith 1 55.0 ± 1.2
WASMaker 3 53.9 ± 2.9
RustSmith 0 53.4 ± 0.3

CLIR detected 8×, 24×, and 8× more unique bugs than cranelift-fuzzgen, wasm-smith, and WASMaker, respectively, and achieved superior overall coverage.

Figure 5

Figure 5: The workflow of CLIR, illustrating corpus-driven hierarchical IR generation, SSA/CFG construction, and cross-architecture differential testing.

Test Case Complexity

CLIR test cases demonstrate higher median cyclomatic complexity, dominator tree depth, instruction diversity, and def-use chain length relative to all baselines, with the exception of WebAssembly-centric tools that have inherent bias toward deep stack-based chains Figure 6.

Figure 6

Figure 6: The distribution of the complexity of generated test cases: (a) cyclomatic complexity, (b) dominator tree depth, (c) def-use chain depth, (d) instruction diversity.

Component Contributions

Ablation studies confirm the necessity of both structure-aware CFG assembly and liveness-guided refinement. Variants omitting either produce more test cases but detect fewer bugs and achieve lower coverage, validating that test generation throughput cannot compensate for loss of programmatic depth and persistent liveness.

Bug Characterization and Theoretical Implications

The 24 unique bugs revealed by CLIR comprise 8 miscompilations and 16 backend crashes, distributed across target-specific lowering, platform-independent optimization, and interpreter stages. Several representative cases include miscompilations due to malformed lowering rules for endianness handling, register state clobbering across call boundaries, and architecture-specific register allocation errors that only manifest in unoptimized code.

The diagnosis-guided clustering and reduction workflow proved actionable: 21 bugs were confirmed by Cranelift maintainers and 9 fixed within the study period, influencing both development prioritization and the open-source contribution pipeline.

Practical and Theoretical Impact

CLIR demonstrates that structured, liveness-guided, and corpus-driven IR generation is critical for uncovering deep, non-trivial compiler backend defects that evade source-level and random fuzzing-based techniques. The decoupling of IR test case generation from high-level language frontend constraints circumvents normalization bottlenecks and exposes backend logic deficiencies. Furthermore, cross-architecture analysis supported by flexible configuration profiles provides a scalable approach to mass differential testing for modern polyglot compiler backends.

Conclusion

CLIR establishes a comprehensive methodology for effective fuzzing of modern, multi-architecture backend compilers. By integrating syntax-preserved IR construction, liveness maximization, and feedback-driven cross-architecture adaptation, CLIR sets a new benchmark for coverage and bug discovery in the Cranelift context. The implications for future compiler engineering are significant: the methodology is extensible to other SSA-based or IR-centric compiler infrastructures given only moderate engineering to port the building blocks and architecture profiles. Continued evolution of structure- and liveness-aware program synthesis, in concert with scalable differential diagnosis, will be increasingly central for backend correctness assurance as compiler architectures grow in diversity and complexity.


References

  • "CLIR: Liveness-Driven and Structure-Aware Fuzzing for the Cranelift Compiler" (2606.26977)

Paper to Video (Beta)

No one has generated a video about this paper yet.

Whiteboard

No one has generated a whiteboard explanation for this paper yet.

Open Problems

We haven't generated a list of open problems mentioned in this paper yet.

Tweets

Sign up for free to view the 1 tweet with 3 likes about this paper.