[PATCH] D71228: [Commandline] Move Debug options from Debug.cpp to Commandline.cpp

Don Hinton via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 10 14:46:46 PST 2019


hintonda added a comment.

In D71228#1778285 <https://reviews.llvm.org/D71228#1778285>, @hintonda wrote:

> In D71228#1777711 <https://reviews.llvm.org/D71228#1777711>, @serge-sans-paille wrote:
>
> > > This patch moves Debug options into CommandLine.cpp so they are only constructed if parseCommandLineOptions is actually called.
> >
> > This would be the case if the options were static to the ` parseCommandLineOptions`, but I fail ti understand why current change gives this property. Can you explain me why?
>
>
> When you statically link in LLVMSupport, you only load what you reference.  In the case of Debug options, they are referenced all over, so that TU gets loaded.  If it also included static Options, which register themselves with the global parser in CommandLine.cpp, that TU gets loaded as well.  By moving the Debug options over to CommandLine.cpp, those statics won't be loaded unless the TU is loaded, which will only happened if the user calls function in CommandLine.cpp.
>
> We have a case where we use functionality in LLVMSupport, but don't call parseCommandLineOptions.  We can still access the DebugFlag, etc, but don't actually need the option since it is only used by the parser -- those options use cl::location, so the global already exists.  Hope that makes sense.


Btw, this is true for any symbol in CommandLine.cpp, not just parseCommandLineOptions.  Sorry if I wasn't clear.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71228/new/

https://reviews.llvm.org/D71228





More information about the llvm-commits mailing list