Now we are implementing a analysis pass for llvm, following this tutorial. and need to pass an additional argument to the plugin such as below:
opt -load /path/to/myplugin.so -mypass -mypass_option input.bc
However I did not find any manual telling me how to do. So I'm wondering whether it is possible in practice.
Thanks in advance.
You should use the CommandLine library which comes built-in with LLVM. Basically, you just put at the top of the .cpp file of the pass:
But I recommend you check the above link, it has full reference + convenient quickstart section.
For an example, take a look at the built-in loop unrolling pass - it defines two unsigned and two boolean options, right at the top of the source file, by using
cl::opt<unsigned>
andcl::opt<bool>
.