What this book covers
Chapter 1, Saving Resources When Building LLVM, gives a brief introduction to the LLVM project, before showing you how to build LLVM without draining your CPU, memory resources, and disk space. This paves the road to shorter development cycles and smoother experiences for later chapters.
Chapter 2, Exploring LLVM's Build System Features, shows you how to write CMake build scripts for both in-tree and out-of-tree LLVM development. You will learn crucial skills to leverage LLVM's custom build system features to write more expressive and robust build scripts.
Chapter 3, Testing with LLVM LIT, shows you the way to run testing with LLVM's LIT infrastructure. The chapter not only gives you a better understanding of how testing works in LLVM's source tree but also enables you to integrate this intuitive, scalable testing infrastructure into any project.
Chapter 4, TableGen Development, shows you how to write TableGen – a special Domain Specific Language (DSL) invented by LLVM. We especially focus on using TableGen as a general tool for processing structural data, giving you flexible skills to use TableGen outside LLVM.
Chapter 5, Exploring Clang's Architecture, marks the start of our topics on Clang. This chapter gives you an overview of Clang, especially its compilation flow, and presents to you the role of individual components in Clang's compilation flow.
Chapter 6, Extending the Preprocessor, shows you the architecture of the preprocessor in Clang and, more importantly, shows you how to develop a plugin to extend its functionalities without modifying any code in the LLVM source tree.
Chapter 7, Handling AST, shows you how to develop with an Abstract Syntax Tree (AST) in Clang. The content includes learning important topics to work with an AST's in-memory representation and a tutorial to create a plugin that inserts custom AST processing logic into the compilation flow.
Chapter 8, Working with Compiler Flags and Toolchains, covers the steps to add custom compiler flags and toolchains to Clang. Both skills are especially crucial if you want to support new features or new platforms in Clang.
Chapter 9, Working with PassManager and AnalysisManager, marks the start of our discussion on the LLVM middle-end. This chapter focuses on writing an LLVM pass – using the latest new PassManager syntax – and how to access program analysis data via AnalysisManager.
Chapter 10, Processing LLVM IR, is a big chapter containing a variety of core knowledge regarding LLVM IR, including the structure of LLVM IR's in-memory representation and useful skills to work with different IR units such as functions, instructions, and loops.
Chapter 11, Gearing Up with Support Utilities, introduces some utilities that can improve your productivity – such as having better debugging experiences – when working with LLVM IR.
Chapter 12, Learning LLVM IR Instrumentation, shows you how instrumentation works on LLVM IR. It covers two primary use cases: Sanitizer and Profile-Guided Optimization (PGO). For the former, you will learn how to create a custom sanitizer. For the latter, you will learn how to leverage PGO data in your LLVM Pass.