Multi-Level IR Compiler Framework

Getting Started

Don’t miss the MLIR Tutorial! slides - recording - online step-by-step

Please refer to the LLVM Getting Started in general to build LLVM. Below are quick instructions to build MLIR with LLVM.

The following instructions for compiling and testing MLIR assume that you have git, ninja, and a working C++ toolchain (see LLVM requirements).

As a starter, you may try the tutorial on building a compiler for a Toy language.


See the Testing Guide - CLI Incantations section for additional ways to invoke and filter tests that can help you be more efficient for regular development.

Unix-like compile/testing:

git clone
mkdir llvm-project/build
cd llvm-project/build
cmake -G Ninja ../llvm \
# Using clang and lld speeds up the build, we recommend adding:
# CCache can drastically speed up further rebuilds, try adding:
# Optionally, using ASAN/UBSAN can find bugs early in development, enable with:
# -DLLVM_USE_SANITIZER="Address;Undefined"
# Optionally, enabling integration tests as well
cmake --build . --target check-mlir

It is recommended that you install clang and lld on your machine (sudo apt-get install clang lld on Ubuntu for example) and uncomment the last part of the cmake invocation above.

If you need debug info, you can use -DCMAKE_BUILD_TYPE=Debug or -DCMAKE_BUILD_TYPE=RelWithDebInfo. It is recommended to use -DLLVM_USE_SPLIT_DWARF=ON to save ~ 30%-40% disk space with debug builds.

Windows compile/testing:

To compile and test on Windows using Visual Studio 2017:

REM In shell with Visual Studio environment set up, e.g., with command such as
REM   $visual-studio-install\Auxiliary\Build\vcvarsall.bat" x64
REM invoked.
git clone
mkdir llvm-project\build
cd llvm-project\build
cmake --build . --target tools/mlir/test/check-mlir

Getting Started Docs