This is a tutorial on writing LLVM passes targeting beginners and newcomers. It focuses on out-of-tree development and is based on LLVM 9 (i.e. the latest release). You will learn how to register a pass (legacy vs new pass manager) and how to build a standalone LLVM-based analysis and transformation tools. Testing will be set-up using LIT - LLVM's testing infrastructure. You will see how to configure the necessary scripts, implement tests and fix them when failing.
This tutorial is self-contained and no prior knowledge of LLVM or compilers is required. Some familiarity with CMake and LLVM IR (or any other assembly language) will be helpful, but is not essential. The presented examples can be tested with pre-build packages available online (i.e. building LLVM from sources is optional). All examples will be available on GitHub.
Content: * implementing a pass (including CMake set-up) * registering a pass, new vs legacy pass manager * examples of analysis and transformation passes (IR <-> IR) * running and debugging an out-of-tree pass * integrating a pass into an out-of-tree LLVM-based tool * setting up and running LIT tests for out-of-tree passes * integration with clang/opt/bugpoint