[LLVMdev] Passing parameters to LLVM optimisation passes
criswell at uiuc.edu
Wed Feb 27 09:42:29 CST 2008
Ian Jason wrote:
> I'm fairly new to LLVM, and am writing an optimisation pass to be run by
> 'opt'. However, i'd like this pass to be parameterisable; as such i'd like
> to be able to pass an option to it (preferably via the command line to
> e.g. so i can do something like this "opt -load mypass.so
> -MyPass=MyPassOption < inputfile.bc ..."
Yes, this is possible. In your source code, you simply need to add a
new command line option using LLVM's command line library. This library
allows you to create a global variable for each command line option that
you want. When you load your pass into opt, the global variables'
constructors automatically register your command line options with the
For example, you might do something like this in your code:
cl::opt<bool> OnlyPrintMain("only-print-main-ds", cl::ReallyHidden);
This defines a command line option "-only-print-main-ds" that toggles a
boolean flag. The OnlyPrintMain variable than acts like a C++ boolean:
do something else
More information on the command line library can be found in its
-- John T.
> (for example one thing I would like to do is pass a list of function names
> to optimise, the pass would then optimise these (and their children) and
> ignore everything else)
> I've had a trawl through the documentation but can't seem to see a way of
> doing this within the pass framework. I may be missing something. Is it
> possible? If so, could someone point me in the right direction?
> View this message in context: http://www.nabble.com/Passing-parameters-to-LLVM-optimisation-passes-tp15711960p15711960.html
> Sent from the LLVM - Dev mailing list archive at Nabble.com.
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
More information about the LLVMdev