[llvm-dev] How to include a opt pass in clang driver

Soham Sinha via llvm-dev llvm-dev at lists.llvm.org
Mon Jun 25 13:38:51 PDT 2018


I have written a pass for the IR and I can run it with opt -load
lib/LLVMMyPass.so -mypass -myarguments -S -o output.ll < output.bc

I have registered my pass with the following code:
static RegisterPass<MyPass>
X("mypass", "MyPass Pass (with getAnalysisUsage implemented)");

How do I include the same pass in the clang driver. I tried running the

clang output.c -o output -Xclang -load -Xclang lib/LLVMMyPass.so -mypass

However, the pass is not being run as I cannot see output from my pass.
What is the standard way to do it?

I have also tried approach described here:
https://www.cs.cornell.edu/~asampson/blog/clangpass.html . It didn't work.

Soham Sinha
PhD Student, Department of Computer Science
Boston University
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180625/ff50e226/attachment.html>

More information about the llvm-dev mailing list