Writing an inlining transformation pass

As we know, by inlining we mean expanding the function body of the function called at the call site, as it may prove useful through faster execution of code. The compiler takes the decision whether to inline a function or not. In this recipe, you will learn to how to write a simple function-inlining pass that makes use of the implementation in LLVM for inlining. We will write a pass that will handle the functions marked with the alwaysinline attribute.

Getting ready

Let's write a test code that we will run our pass on. Make the necessary changes in the lib/Transforms/IPO/IPO.cpp and include/llvm/InitializePasses.h files, the include/llvm/Transforms/IPO.h file, and the /include/llvm-c/Transforms/IPO.h file ...

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.