TAGS :Viewed: 10 - Published at: a few seconds ago

[ How can I create a non-plugin LLVM pass? ]

I have built LLVM/Clang under Linux, and followed the instructions at http://llvm.org/docs/WritingAnLLVMPass.html to create an LLVM shared object pass plugin. The plugin can then be loaded using LLVM's opt program and the -load switch. Based on the LLVMHello and LLVMHello2 examples, I have now created a pass of my own.

Is a plugin the only method I can use to incorporate a pass into LLVM/Clang? I would like to build my pass directly in to the LLVM/Clang source, but I'm not sure where to begin.

Answer 1


Just link your pass to opt and it will be available there. All standard passes are in lib/Transforms/*, so you can use them as examples.

Answer 2


Basically, you can just copy your source into lib/Transforms/ and adjust build system files. Here is info on how to do it with CMake: http://llvm.org/docs/CMake.html#passdev