[LLVMdev] Using custom LLVM Passes with clang

Rakesh Varna rvarna at eng.ucsd.edu
Fri Nov 16 01:43:41 PST 2012

    I have written a custom LLVM Loop Pass that perforates a loop by
changing the increment value for the induction variable. I am able to run
this pass using the opt command and loading the shared object library from
Debug+Asserts as detailed in http://llvm.org/docs/WritingAnLLVMPass.html

I was wondering if this pass can be used in clang somehow. I have read
about "-mllvm" option which can be used to pass arguments to LLVM from
clang. But I have not been able to get this to work.
I tried a similar way of running clang (as I did with opt)
clang -load "path_to_library" -mllvm "registered_custom_pass_option" test.c
-o test.o

It complains that the load option was unused during compilation, Also, that
it cannot find any option by -loop-perforate which is the registered custom

I tried using -indvars,along with -mllvm to see if I am doing it right. But
I get the same error for -indvars too. Isn't that supported by default ( i
can see it printed in -mllvm -debug-pass=Arguments)

Am I doing something completely wrong here? How can I get the custom pass
to work with clang and also specify only certain passes like -indvars?

Thank you in advance.

Rakesh Varna
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20121116/c8c5995c/attachment.html>

More information about the llvm-dev mailing list