First-Class Verification Dialects for MLIR
Open Access
- 10 June 2025
- journal article
- Published by Association for Computing Machinery (ACM) in Proceedings of the ACM on Programming Languages
- Vol. 9 (PLDI) , 1466-1490
Abstract
MLIR is a toolkit supporting the development of extensible and composable intermediate representations (IRs) called dialects ; it was created in response to rapid changes in hardware platforms, programming languages, and application domains such as machine learning. MLIR supports development teams creating compilers and compiler-adjacent tools by factoring out common infrastructure such as parsers and printers. A major limitation of MLIR is that it is syntax-focused: it has no support for directly encoding the semantics of operations in its dialects. Thus, at present, the parts of MLIR tools that depend on semantics—optimizers, analyzers, verifiers, transformers—must all be engineered by hand. Our work makes formal semantics a first-class citizen in the MLIR ecosystem. We designed and implemented a collection of semantics-supporting MLIR dialects for encoding the semantics of compiler IRs. These dialects support a separation of concerns between three domains of expertise when building formal-methods-based tooling for compilers. First, compiler developers define their dialect’s semantics as a lowering (compilation transformation) from their dialect to one or more of ours. Second, SMT solver experts provide tools to optimize domain-specific high-level semantics and lower them to SMT queries. Third, tool builders create dialect-independent verification tools. We validate our work by defining semantics for five key MLIR dialects, defining a state-of-the-art SMT encoding for memory-based semantics, and building three dialect-agnostic tools, which we used to find five miscompilation bugs in upstream MLIR, verify a canonicalization pass, and also formally verify transfer functions for two dataflow analyses: “known bits” (that finds individual bits that are always zero or one in all executions) and “demanded bits” (that finds don’t-care bits). The transfer functions that we verify are improved versions of those in upstream MLIR; they detect on average 36.6% more known bits in real-world MLIR programs compared to the upstream implementation.Keywords
Funding Information
- Engineering and Physical Sciences Research Council (EP/W007940/1)
- HORIZON EUROPE Reforming and enhancing the European Research and Innovation system (101070375)
- National Science Foundation (1955688)
This publication has 33 references indexed in Scilit:
- High-Throughput, Formal-Methods-Assisted Fuzzing for LLVM2024
- SMT-Based Translation Validation for Machine Learning Compiler2022
- An SMT Encoding of LLVM’s Memory Model for Bounded Translation Validation2021
- MLIR: Scaling Compiler Infrastructure for Domain Specific Computation2021
- Towards Bit-Width-Independent Proofs in SMT Solvers2019
- Viper: A Verification Infrastructure for Permission-Based Reasoning2015
- Why3 — Where Programs Meet Provers2013
- Equality-Based Translation Validator for LLVM2011
- Boogie: A Modular Reusable Verifier for Object-Oriented Programs2006
- Automated soundness proofs for dataflow analyses and transformations via local rules2005