[LLVMdev] Tutorial on writing Link Time Optimization Passes?

Diego Huang diego.huang at utoronto.ca
Mon Dec 8 14:51:15 PST 2008


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
>







More information about the llvm-dev mailing list