<div dir="ltr"><div style="font-family:tahoma,sans-serif" class="gmail_default">very simple and good commands :</div><div style="font-family:tahoma,sans-serif" class="gmail_default"> </div><div style="font-family:tahoma,sans-serif" class="gmail_default"><create basic_block_pass.cpp with pass name myPass in any location></div><div style="font-family:tahoma,sans-serif" class="gmail_default"> </div><div style="font-family:tahoma,sans-serif" class="gmail_default">$ clang++ -c basic_block_pass.cpp `llvm-config --cxxflags`<br>$ clang++ -shared -o pass.so basic_block_pass.o `llvm-config --ldflags`<br>$ opt -load ./pass.so -myPass < hello.bc > /dev/null<br></div><div style="font-family:tahoma,sans-serif" class="gmail_default">link : <a href="http://stackoverflow.com/questions/22007458/how-to-create-you-own-pass-in-llvm?rq=1">http://stackoverflow.com/questions/22007458/how-to-create-you-own-pass-in-llvm?rq=1</a>​</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Nov 8, 2014 at 10:03 AM, Dan Liew <span dir="ltr"><<a href="mailto:dan@su-root.co.uk" target="_blank">dan@su-root.co.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span><p dir="ltr">> It ought to be possible to compile your own pass to a .so file and<br>
> load it into opt dynamically. There's some kind of documentation at<br>
> <a href="http://llvm.org/docs/CMake.html#cmake-out-of-source-pass" target="_blank">http://llvm.org/docs/CMake.html#cmake-out-of-source-pass</a>, but I've not<br>
> done it before so I don't know how reliable it is.</p>
</span><p dir="ltr">It is indeed possible. I have a simple example of doing this for the "hello pass" in [1] in the "helloPass" folder. In the same directory it also shows how to load the pass as a clang plug-in and have it run automatically. This built fine against LLVM3.5 but I've not tested if this builds against trunk.</p>
<p dir="ltr">[1] <a href="https://github.com/delcypher/srg-llvm-pass-tutorial/" target="_blank">https://github.com/delcypher/srg-llvm-pass-tutorial/</a></p>
<p dir="ltr">HTH,<br>
Dan<br>
</p>
<br>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
<br></blockquote></div><br></div>