Continuing: How to write a custom LTO pass?

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 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

As I read in the thread from 2015
( 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.



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.