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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

George Karpenkov via llvm-dev
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
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

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

George Karpenkov via llvm-dev
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 <[hidden email]>:
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
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


_______________________________________________
LLVM Developers mailing list
[hidden email]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Loading...