DESIL: Detecting Silent Bugs in MLIR Compiler Infrastructure

Chenyao Suo, Jianrong Wang, Yongjia Wang, Jiajun Jiang, QingChao Shen, Junjie Chen · 2025

Read DESIL: Detecting Silent Bugs in MLIR Compiler Infrastructure by Chenyao Suo, Jianrong Wang, Yongjia Wang, Jiajun Jiang, QingChao Shen, Junjie Chen (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2504-01379.txt.

Introduction

Chenyao Suo and five co-authors built a tool that hunts silent bugs in a widely used compiler framework, in a 2025 paper. Silent bugs are the nastiest kind: the compiler quietly produces wrong code instead of crashing. MLIR, a framework for building compilers, had fuzzers that found crashes but not silent mis-optimizations. Two hurdles block the hunt: test programs must avoid undefined behavior, and programs must be lowered to runnable form to compare outputs.

Their tool, DESIL, applies rules drawn from MLIR's own documentation to scrub undefined behavior from generated programs. A smart lowering strategy then picks efficient paths to executable code, and varied optimization choices create outputs to compare. Run against the newest MLIR code, it found twenty-three silent bugs and nineteen crashes. Developers confirmed or fixed many of them, the authors report.

Catalog record

CREATORChenyao Suo, Jianrong Wang, Yongjia Wang, Jiajun Jiang, QingChao Shen, Junjie Chen
YEAR2025
COLLECTIONPAPERS
FORMATTXT
FILE SIZE87 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2504-01379

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

DESIL: Detecting Silent Bugs in MLIR Compiler Infrastructure Chenyao Suo, Jianrong Wang, Yongjia Wang, Jiajun Jiang, QingChao Shen, Junjie Chen Abstract . MLIR (Multi-Level Intermediate Representation) compiler infrastructure provides an efficient framework for introducing a new abstraction level for programming languages and domain-specific languages. It has attracted widespread attention in recent years and has been applied in various domains, such as deep learning compiler construction. Recently, several MLIR compiler fuzzing techniques, such as MLIRSmith and MLIRod, have been proposed. However, none of them can detect silent bugs, i.e., bugs that incorrectly optimize code silently. The difficulty in detecting silent bugs arises from two main aspects: (1) UB-Free Program Generation : Ensures the generated programs are free from undefined behaviors to suit the non-UB assumptions required by compiler optimizations. (2) Lowering Support : Converts the given MLIR program into an executable form, enabling execution result comparisons, and selects a suitable lowering path for the program to reduce redundant lowering pass and improve the efficiency of fuzzing. To address the above issues, we propose DESIL. DESIL enables silent bug detection by defining a set of UB-elimination rules based on the MLIR documentation and applying them to input programs to produce UB-free MLIR programs. To convert dialects in MLIR program into the executable form, DESIL designs a lowering path optimization strategy to convert the dialects in given MLIR program into executable form. Furthermore, DESIL incorporates the differential testing for silent bug detection. To achieve this, it introduces an operation-aware optimization recommendation strategy into the compilation process to generate diverse executable files. We applied DESIL to the latest revisions of the MLIR compiler infrastructure. It detected 23 silent bugs and 19 crash bugs, of which 12/14 have been confirmed or fixed. 1. Introduction The MLIR (Multi-Level Intermediate Representation) compiler infrastructure is a powerful and extensible framework designed to facilitate compiler construction across diverse domains, including machine learning, high-performance computing, and hardware accelerators ( Lattner et al., 2021 ) . By providing a structured representation at multiple abstraction levels, MLIR enables efficient transformations, optimizations, and target-specific code generation, making it a cornerstone of modern compiler design. However, given its growing adoption in critical applications such as deep learning and hardware synthesis, ensuring the correctness of MLIR is paramount. Particularly, bugs in MLIR can propagate through the compilation pipeline, leading to incorrect program execution, degraded performance, or even security vulnerabilities ( Suo et al., 2024 ; Wang et al., 2023 ) . Therefore, rigorous testing techniques are essential, ensuring that MLIR remains a robust and trustworthy infrastructure for compiler development and optimization. Due to the unique characteristics of MLIR (such as its use of dialects to manage multi-level IRs and its proprietary data structures and semantics), traditional compiler testing techniques are largely inapplicable. Therefore, in recent years, some testing techniques tailored to the MLIR compiler infrastructure have been proposed ( Suo et al., 2024 ; Wang et al., 2023 ) . For example, MLIRSmith ( Wang et al., 2023 ) generates MLIR programs based on its grammar for the testing purpose. MLIRod ( Suo et al., 2024 ) mutates existing MLIR programs for testing, guided by the diversity of operation dependencies within MLIR programs. However, these techniques are limited to detecting crash bugs, failing to capture silent bugs (also known as wrong code bugs ( Yang et al., 2011 ) ), which generate incorrect executable code without triggering crashes. This limitation arises due to the challenging issue of undefined behavior (UB) — a scenario where program execution lacks a well-defined outcome due to violations of language specifications, leading to unpredictable execution results ( Yang et al., 2011 ) . Note that silent compiler bugs pose a severe risk, as they can go unnoticed during compilation and cause erroneous behaviors at runtime, potentially leading to critical failures in real-world applications. In the literature, eliminating UB has been recognized as an important yet challenging task ( Yang et al., 2011 ; Livinskii et al., 2020 ; Lecoeur et al., 2023 ; Livinskii et al., 2023 ) . This challenge arises from the diverse root causes of UB — such as memory safety violations, uninitialized variables, integer overflows, and type mismatches — which can emerge at any stage of compilation and propagate silently through optimizations. The unique characteristics of MLIR further exacerbate this problem. Specifically, MLIR supports multiple dialects, each with its own operations, attributes, and verification rules, significantly expanding the scope of potential UB. Moreover, MLIR introduces dialect-specific UB root causes, such as shape inconsistency in memref and linalg dialects, which require specialized runtime checks and analysis for effective detection and elimination. Unlike traditional programming languages, MLIR lacks dedicated UB detection tools, making even well-known UB issues more difficult to identify and mitigate. Assuming UB-free MLIR programs can be obtained, using them to detect silent bugs still faces the compilation challenge — the process of transforming an MLIR program into an executable form (i.e., solely represented by the llvm or spirv dialect). This challenge arises because MLIR programs often require multiple lowering stages across different dialects (especially their operations) before reaching a fully executable representation. Specifically, an MLIR program may contain operations from various dialects, each necessitating specific lowering passes to transition into an executable representation. For ease of presentation, we call a sequence of lowering passes to transform a dialect operation to the specified executable dialect an operation-specific lowering path , and a sequence of lowering passes to transform an MLIR program to the executable form a lowering path . Furthermore, new dialects can be introduced dynamically during the lowering process, leading to an expansive and evolving space of possible lowering paths. While an exhaustive enumeration of all possible lowering sequences could theoretically ensure successful compilation, it would impose a significant efficiency bottleneck — a crucial factor in compiler testing ( Chen et al., 2016 ) . Therefore, determining an appropriate lowering path is essential to balance compilation feasibility and testing efficiency, enabling more effective detection of silent bugs. To bridge the gap in detecting silent MLIR bugs, we propose DESIL ( DE tecting SIL ent bugs), a novel technique that jointly generates UB-free programs and determines an optimal lowering path for each program to facilitate effective bug detection. Specifically, to tackle the first challenge, DESIL designs a set of MLIR program transformation rules to eliminate UB in UB-prone operations. For example, to address the UB-prone operation of copying a memref variable to another when both have dynamic shapes, DESIL introduces a transformation rule that replaces the source memref value with one that deterministically matches the destination variable’s shape. Notably, DESIL tackles the UB issue through post-processing of already-generated MLIR programs, making it orthogonal to existing MLIR testing techniques. This allows DESIL to be seamlessly combined with them, enhancing the detection of silent bugs and demonstrating its practicality. To tackle the second challenge, DESIL determines an optimal lowering path that prevents redundant or circular application of lowering passes, ensuring efficient compilation to an executable representation. Specifically, DESIL first builds a mapping between lowering passes and dialect operations based on MLIR documentation, recording an operation-specific lowering path for each operation. Then, given an MLIR program, DESIL determines its optimal lowering path by performing topological sorting on the lowering

Read the complete text