[LLVMdev] Tutorial on writing Link Time Optimization Passes?
Nick Lewycky
nicholas at mxc.ca
Mon Dec 8 10:05:07 PST 2008
The documentation you're looking for is:
http://llvm.org/docs/WritingAnLLVMPass.html
If you're doing an optimization that runs at link-time, you'll probably
be writing a ModulePass. You can run any pass at any time over any
bitcode file with 'opt -mypass file.bc'. If you want to add it to the
list of passes that run when linking via libLTO or llvm-ld, you can add
it to the list in tools/llvm-ld/Optimize.cpp:Optimize and
tools/lto/LTOCodeGenerator.cpp:generateAssemblyCode.
A couple other pointers to our doxygen:
ModulePass: http://llvm.org/doxygen/classllvm_1_1ModulePass.html
CallGraph: http://llvm.org/doxygen/classllvm_1_1CallGraph.html
You can take a look at lib/Transforms/IPO/Internalize.cpp to see an
example of a link-time optimization pass that uses the CallGraph.
Nick
Diego Huang wrote:
> Hi,
>
> Is there a tutorial on how to get started with writing link-time
> optimization passes? The documentation at
> http://www.llvm.org/docs/LinkTimeOptimization.html explains the design
> of the LTO interface, but does not explain where to start writing
> code. Would my pass go inside libLTO.a or is it separate from
> libLTO.a? What I would like to be able to do is traverse through the
> entire call graph of the program, which is only available at link-time.
>
> Thank you,
>
> Diego
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
More information about the llvm-dev
mailing list