- Our build files are
BUILDin almost all cases, notBUILD.bazel.
- When creating operations, always use the format
OpType::create(rewriter, ...)and never use the (deprecated) formatrewriter.create<OpType>(...). - When writing unit tests with filecheck, never use
CHECK-LABEL; just useCHECKinstead.
scripts/templates/templates.py(which requirespython-fireandjinja2) provides boilerplate for generating new transforms and passes. After running the script to create a new pass, one still must register the pass inheir-opt.cppand add the necessary build dependencies.
Copied from https://mlir.llvm.org/docs/Tutorials/MlirOpt/ with minor tweaks.
--mlir-timingdisplays execution times of each pass.--debugprints all debug information produced byLLVM_DEBUGorLDBGcalls.--debug-only="my-tag"prints only the debug information produced byLLVM_DEBUGin files that have the macro#define DEBUG_TYPE "my-tag". This often allows you to print only debug information associated with a specific pass."greedy-rewriter"only prints debug information for patterns applied with the greedy rewriter engine."dialect-conversion"only prints debug information for the dialect conversion framework.
--dump-pass-pipelineprints the full pipeline that will be run before starting.--mlir-print-ir-after-allprints the IR after each pass.- See also
--mlir-print-ir-after-change,--mlir-print-ir-after-failure, and analogous versions of these flags withbeforeinstead ofafter. - When using
print-irflags, adding--mlir-print-ir-tree-dirwrites the IRs to files in a directory tree, making them easier to inspect versus a large dump to the terminal. A common practice when encountering a segfault is to create a minimal reproducing test case by adding--dump-pass-pipeline --mlir-print-ir-before-all --mlir-print-ir-tree-dir=/tmp/mlir, copying the last IR file (filenames are prefixed by the number of the pass in the pipeline) and running the single failing pass on it, using the output of--dump-pass-pipelineto get the pass options.
- See also