[llvm-dev] Continuing: How to write a custom LTO pass?

Mehdi AMINI via llvm-dev llvm-dev at lists.llvm.org
Sat Aug 12 11:49:40 PDT 2017


Hi,

If your pass runs statically with `opt` (i.e. not loaded as a shared
library), the only thing missing is adding it to the pass-manager so that
it'll run during LTO.

In LLVM 3.8 the entry point would be:
`PassManagerBuilder::populateLTOPassManager()`
in lib/Transforms/IPO/PassManagerBuilder.cpp

Best,

-- 
Mehdi



2017-08-04 5:40 GMT-07:00 Oliver Braunsdorf via llvm-dev <
llvm-dev at lists.llvm.org>:

> Hi there,
>
> Can someone please outline the steps to load a custom LTO pass at link
> time?
>
> I wrote a module pass which currently runs under opt to analyze bitcode
> files that have been manually linked using llvm-link.
> [Working with LLVM3.8.0]
>
> Now I want to integrate my custom pass into the a projects build chain.
> I installed gold linker and built LLVMgold.so so that I can use the
> "clang++ -flto" command to compile and link the project with LLVMs LTO
> Passes(at least I believe that the LLVMs LTO passes are executed). I am
> looking for some further command line option for clang to load the
> shared library of my custom module pass.
> Further I need to pass specific command line options to my module pass
> itself.
>
> As I read in the thread from 2015
> (http://lists.llvm.org/pipermail/llvm-dev/2015-May/085744.html) I have
> to modify files in llvm/tools/LTO or in llvm/lib/LTO to accomplish this.
> Is that still true? Can someone please give me more detailed
> instructions? Because the old thread is missing a lot of details and I
> cannot find information in the LLVM documentation.
>
> Thanks,
> Oliver
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20170812/3589d2cd/attachment.html>


More information about the llvm-dev mailing list