[llvm-dev] llvm pass

Philip Pfaffe via llvm-dev llvm-dev at lists.llvm.org
Mon May 27 03:33:41 PDT 2019

Hi Kihong,

> 1) Is building a custom LLVM pass out-of-source not recommended?
The official document only contains instructions about in-source build (
> http://llvm.org/docs/WritingAnLLVMPass.html).
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.

> 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:
Did you build your plugin against LLVM >= 4?

> 3) I tried to invoke custom LLVM passes from clang rather than opt. I
> followed instructions from several articles like
> https://www.cs.cornell.edu/~asampson/blog/llvm.html
> https://medium.com/@mshockwave/writing-llvm-pass-in-2018-part-iii-d44cd0c2c354
> and registered the pass to clang’s workflow with legacy pass manger. But
> it raises segmentation fault errors.
> What is a recommended way to register custom passes to clang directly?
The articles are  correct in how to do pass registration. In particular,
[this](https://www.cs.cornell.edu/~asampson/blog/clangpass.html) 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.


> Thanks in advance.
> Best,
> Kihong
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://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/20190527/5dc1d846/attachment.html>

More information about the llvm-dev mailing list