Chapter 4. Preparing Optimizations

In this chapter, we will cover the following recipes:

  • Various levels of optimization
  • Writing your own LLVM pass
  • Running your own pass with the opt tool
  • Using another pass in a new pass
  • Registering a pass with pass manager
  • Writing an analysis pass
  • Writing an alias analysis pass
  • Using other analysis passes

Introduction

Once the source code transformation completes, the output is in the LLVM IR form. This IR serves as a common platform for converting into assembly code, depending on the backend. However, before converting into an assembly code, the IR can be optimized to produce more effective code. The IR is in the SSA form, where every new assignment to a variable is a new variable itself—a classic case of an SSA representation. ...

Get LLVM Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.