[LLVMdev] [RFC] Removing static initializers for command line options

Rafael Espíndola rafael.espindola at gmail.com
Tue Aug 19 13:32:45 PDT 2014


>> * Nobs for which there is not a single right answer for all users.
>> There are very few of these currently and we expect it to remain like
>> that. These should not use cl::opt or static storage at all. They
>> should be an option passed to the constructor of the pass.  It may
>> also involve exposing it to the C api and the PassManagerBuilder.
>
> How would you suggest we expose cl::opts for modifying these options in tools like opt? A good example of this type of option would be the options in LoopUnrollPass.cpp.

Opt uses the PassManagerBuilder. Opt itself could have a command line
options controlling its use of PassManagerBuilder. That is probably
fine since we expect very few of these.

>>
>> * Options that we use during development of llvm. They are useful for
>> testing, tracking a bug or enabling/disabling a feature that is still
>> under development. These can use a static storage since external
>> clients like webkit will never change them. We do have to avoid these
>> options requiring static constructors, since otherwise the client is
>> paying for something it will never use.
>
> What about when we're debugging the WebKit JIT? For development of libraries using LLVM it would be nice to be able to toggle these values too, which is why Filip’s suggestion of an API like LLVMConfigSetBoolValue(Config, "ScalarizeLoadStore", 1) would be nice.

Most llvm bugs reproduce with just opt or llc, but if that is not the
case, cl::ParseCommandLineOptions when debugging seems fine.

The advantages of this setup are

* Options that are exposed to the users are done so in a very natural
way (constructor arguments).
* Internal options are still really easy to create, but now don't have
static constructors.
* We don't need a LLVMConfig object that gets passed around.
* No stringly typed interface.

Cheers,
Rafael




More information about the llvm-dev mailing list