Name Date Size #Lines LOC

..--

CMakeLists.txtH A D25-Jul-2023983 5544

README.mdH A D04-Jan-20242.2 KiB5240

mlir-cat.cppH A D20-Oct-20231.8 KiB6144

mlir-minimal-opt-canonicalize.cppH A D25-Jul-2023816 228

mlir-minimal-opt.cppH A D25-Jul-2023813 196

README.md

1# Minimal MLIR binaries
2
3This folder contains example of minimal MLIR setups that can showcase the
4intended binary footprint of the framework.
5
6- mlir-cat: This includes the Core IR, the builtin dialect, the textual
7  parser/printer, the support for bytecode serialization.
8- mlir-minimal-opt: This adds all the tooling for an mlir-opt tool: the pass
9  infrastructure and all the instrumentation associated with it.
10- mlir-miminal-opt-canonicalize: This add the canonicalizer pass, which pulls in
11  all the pattern/rewrite machinery, including the PDL compiler and intepreter.
12
13Below are some example measurements taken at the time of the LLVM 17 release,
14using clang-14 on a X86 Ubuntu and [bloaty](https://github.com/google/bloaty).
15
16|                                  | Base   | Os     | Oz     | Os LTO | Oz LTO |
17| :------------------------------: | ------ | ------ | ------ | ------ | ------ |
18| `mlir-cat`                       | 1024KB |  840KB |  885KB |  706KB |  657KB |
19| `mlir-minimal-opt`               | 1.62MB | 1.32MB | 1.36MB | 1.17MB | 1.07MB |
20| `mlir-minimal-opt-canonicalize`  | 1.83MB | 1.40MB | 1.45MB | 1.25MB | 1.14MB |
21
22Base configuration:
23
24```
25cmake ../llvm/ -G Ninja \
26   -DCMAKE_BUILD_TYPE=RelWithDebInfo \
27   -DLLVM_CCACHE_BUILD=ON \
28   -DLLVM_ENABLE_PROJECTS=mlir \
29   -DLLVM_BUILD_EXAMPLES=ON \
30   -DLLVM_TARGETS_TO_BUILD="Native" \
31   -DCMAKE_C_COMPILER=clang \
32   -DCMAKE_CXX_COMPILER=clang++ \
33   -DLLVM_ENABLE_LLD=ON \
34   -DLLVM_ENABLE_BACKTRACES=OFF \
35   -DMLIR_ENABLE_PDL_IN_PATTERNMATCH=OFF \
36   -DCMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO=-Wl,-icf=all
37```
38
39Note: to measure the on-disk size, you need to run `strip bin/mlir-cat` first to
40remove all the debug info (which are useful for `bloaty` though).
41
42The optimization level can be tuned with `-Os` or `-Oz`:
43
44- `-DCMAKE_C_FLAGS_RELWITHDEBINFO="-Os -g -DNDEBUG" -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-Os -g -DNDEBUG"`
45- `-DCMAKE_C_FLAGS_RELWITHDEBINFO="-Oz -g -DNDEBUG" -DCMAKE_CXX_FLAGS_RELWITHDEBINFO="-Oz -g -DNDEBUG"`
46
47Finally LTO can also be enabled with `-DLLVM_ENABLE_LTO=FULL`.
48
49Bloaty can provide measurements using:
50`bloaty bin/mlir-cat -d compileunits --domain=vm` or
51`bloaty bin/mlir-cat -d symbols --demangle=full --domain=vm`
52