[LLVMdev] [RFC] Internal command line options should not be statically initialized.

Pete Cooper peter_cooper at apple.com
Tue Sep 17 10:18:36 PDT 2013


Hey Andy

> One easy pattern to follow is to register the option during pass initialization with all the convenient flags and parameters, but refer to a globally defined option storage that enforces the singleton and provides visibility. As long as pass initialization happens before parseCommandLine, usage should be consistent.
> 
> Strawman:
> 
> cl::optval<bool> MyOption; // Just the storage, no initialization.
> 
> MyPass() {
>  // Only registers an option with the same optval once.
>  Option cl::registerOpt(MyOption, cl::init(false), cl::Hidden,
>                         cl::desc("Descriptive string..."), );
> }
Given Chandler's upcoming work on the pass manager, should we assume that multithreaded passes are a future possibility.  If so, would the above variable need to be static inside the constructor, or is there some better way to initialize it only once?  Or perhaps cl options just don't make any sense in a multithreaded context and you can ignore my ramblings.

Thanks,
Pete
> 
> -Andy
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list