[llvm-dev] llvm pass

Kihong Heo via llvm-dev llvm-dev at lists.llvm.org
Sat May 25 00:30:33 PDT 2019

Hi list,

I have several questions about LLVM pass.

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 <http://llvm.org/docs/WritingAnLLVMPass.html>).

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:

$ opt-3.9 -load ../build/hello/LLVMHelloWorld.so -helloworld hello.bc -S > /dev/null
Hello: main

$ opt-4.0 -load ../build/hello/LLVMHelloWorld.so -helloworld hello.bc -S > /dev/null
opt-4.0: Unknown command line argument '-helloworld'.  Try: 'opt-4.0 -help'
opt-4.0: Did you mean '-loops’?

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://www.cs.cornell.edu/~asampson/blog/llvm.html>
https://medium.com/@mshockwave/writing-llvm-pass-in-2018-part-iii-d44cd0c2c354 <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?

Thanks in advance.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190525/64048d49/attachment.html>

More information about the llvm-dev mailing list