title: How to write a custom intermodular pass in LLVM?
body: <p>I've written a standard Analysis pass in LLVM, by extending the <a href="http://llvm.org/docs/doxygen/html/classllvm_1_1FunctionPass.html" rel="noreferrer">FunctionPass</a> class. Everything seems to make sense.</p>
  
  <p>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.</p>
  
  <p>I know about interprocedural passes in LLVM, via extending the <a href="http://llvm.org/docs/doxygen/html/classllvm_1_1ModulePass.html" rel="noreferrer">ModulePass</a> class, but that only allows analysis within a single module.</p>
  
  <p>I know about <a href="http://llvm.org/docs/LinkTimeOptimization.html" rel="noreferrer">link time optimization (LTO)</a> 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 <em>write</em> an LTO pass.</p>
  
  <p>How can I write an intermodular pass, i.e., a pass that has access to all the modules in an application, in LLVM?</p>