command line option

Dear LLVM'ers (or whatever name you will soon have),

     I want to create a pass option, that I could pass at command line, and that would be visible among many different MachineFunction passes. It would be something like the join-liveintervals used in LiveIntervalAnalysis, but I want my option to be visible among many passes, and not only one. I browsed the documentation, but I did not find the info I was looking for. Could any of you tell me a little about it?
I mean, do I have to write something like:

   static cl::opt<bool>
                 cl::desc("Join compatible live intervals"),

in some .h, and then include it in every pass that would read EnableJoining? Is there a standard way of doing this?



You want to use "external storage" so that the bool value gets put into some other global variable, then you declare the global in the public header. Take a look at how llvm/Target/TargetOptions.h works.


Thank you, Chris. Now it works fine!