Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to write a custom intermodular pass in LLVM?

Tags:

People also ask

What is a pass Manager LLVM?

What is a pass manager? A pass manager schedules transformation passes and analyses to be run on IR in a specific order. Passes can run on an entire module, a single function, or something more abstract such as a strongly connected component (SCC) in a call graph or a loop inside of a function.

What is LLVM module?

An LLVM module is effectively a translation unit or a collection of translation units merged together.


I've written a standard Analysis pass in LLVM, by extending the FunctionPass class. Everything seems to make sense.

Now what I'd like to do is write a couple of intermodular passes, that is, passes that allows me to analyze more than one module at a time. The purpose of one such pass is to construct a call graph of the entire application. The purpose of the other such pass is that I have an idea for an optimization involving function calls and their parameters.

I know about interprocedural passes in LLVM, via extending the ModulePass class, but that only allows analysis within a single module.

I know about link time optimization (LTO) in LLVM, but (a) I'm not quite clear if this is what I want and (b) I've found no examples or documentation on how to actually write an LTO pass.

How can I write an intermodular pass, i.e., a pass that has access to all the modules in an application, in LLVM?