Diego Huang
2008-Dec-08 17:56 UTC
[LLVMdev] Tutorial on writing Link Time Optimization Passes?
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
Chris Lattner
2008-Dec-08 18:02 UTC
[LLVMdev] Tutorial on writing Link Time Optimization Passes?
On Dec 8, 2008, at 9:56 AM, 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.Hi Diego, There are no "lto specific" passes. We just write interprocedural passes and can choose to run them at either compile or link time. For some examples, please see lib/Transforms/IPO. -Chris
Nick Lewycky
2008-Dec-08 18:05 UTC
[LLVMdev] Tutorial on writing Link Time Optimization Passes?
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 >
Diego Huang
2008-Dec-08 22:51 UTC
[LLVMdev] Tutorial on writing Link Time Optimization Passes?
Thanks Nick and Chris for your help! I've been able to install the Hello pass as a link-time pass in llvm-ld :) Now onto the harder part of traversing the call graph and performing transformations... Diego Quoting Nick Lewycky <nicholas at mxc.ca>:> 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 >> > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
Reasonably Related Threads
- [LLVMdev] Tutorial on writing Link Time Optimization Passes?
- [LLVMdev] Performing my own pass with a single command line?
- [LLVMdev] running a module pass via opt on multiple bitcode files
- [LLVMdev] running a module pass via opt on multiple bitcode files
- [LTO] -time-passes and libLTO