<div dir="ltr"><div class="gmail_quote"><div>Hi Kihong, </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><div>1) Is building a custom LLVM pass out-of-source not recommended?</div></div></blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><div>The official document only contains instructions about in-source build (<a href="http://llvm.org/docs/WritingAnLLVMPass.html" target="_blank">http://llvm.org/docs/WritingAnLLVMPass.html</a>).</div></div></blockquote><div>Out-of-tree passes are perfectly fine, but not well documented. All you need to do is find_package() the llvm you want to build against and include its AddLLVM module. Then effectively all the details discussed in the how-to you linked work exactly the same.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><div></div><div>2) opt (ver >= 4) with custom pass libraries does not work as before. When I have a simple custom LLVM pass called “helloworld", loading the library works well with 3.9 but opt-4.0 cannot not find the pass:</div></div></blockquote><div>Did you build your plugin against LLVM >= 4? </div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><div>3) I tried to invoke custom LLVM passes from clang rather than opt. I followed instructions from several articles like</div><div><a href="https://www.cs.cornell.edu/~asampson/blog/llvm.html" target="_blank">https://www.cs.cornell.edu/~asampson/blog/llvm.html</a></div><div><a href="https://medium.com/@mshockwave/writing-llvm-pass-in-2018-part-iii-d44cd0c2c354" target="_blank">https://medium.com/@mshockwave/writing-llvm-pass-in-2018-part-iii-d44cd0c2c354</a></div><div>and registered the pass to clang’s workflow with legacy pass manger. But it raises segmentation fault errors.</div><div>What is a recommended way to register custom passes to clang directly?</div></div></blockquote><div>The articles are correct in how to do pass registration. In particular, [this](<a href="https://www.cs.cornell.edu/~asampson/blog/clangpass.html">https://www.cs.cornell.edu/~asampson/blog/clangpass.html</a>) is how you do it. Hard to guess where you bugs are without having seen the code. Again, is the clang version the same as the LLVM version you build your plugin against.</div><div><br></div><div>Cheers,</div><div>Philip</div><div><br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="overflow-wrap: break-word;"><div><br></div><div>Thanks in advance.</div><div><br></div><div>Best,</div><div>Kihong</div></div>_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div></div>