Chapter 5. Implementing Optimizations

In this chapter, we will cover the following recipes:

  • Writing a dead code elimination pass
  • Writing an inlining transformation pass
  • Writing a pass for memory optimization
  • Combining LLVM IR
  • Transforming and optimizing loops
  • Reassociating expressions
  • Vectorizing IR
  • Other optimization passes

Introduction

In the previous chapter, we saw how to write a pass in LLVM. We also demonstrated writing a few analysis passes with an example of alias analysis. Those passes just read the source code and gave us information about it. In this chapter, we will go further and write transformation passes that will actually change the source code, trying to optimize it for the faster execution of code. In the first two recipes, we will show ...

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.