Support/CommandLine.h exposed through Pass.h?

Hi,

In writing llvmc, I need to link in the Bytecode reader in order to
extract the "dependent libraries" from the bytecode files. And, bytecode
reader needs vmcore. And, vmcore has a static cl::opt<bool> named
"EnableTiming" for the -time-passes option. This conflicts at runtime
with llvmc's -time-passes option (which it passes through to
sub-tools).

So, my solution is to declare the EnableTiming global var in Pass.h,
remove its "static" keyword in Pass.cpp and expose
"Support/CommandLine.h" in Pass.h.

This compiles and works fine in all tools, but its a bit gross to expose
CommandLine.h via Pass.h.

Anyone object?

An alternative is to remove EnableTiming from VMCore completely (it
really doesn't belong there) and have callers pass in a boolean if they
want timing. Then each of the tools can define their own option and
provide the boolean value as a constructor argument for a Pass?

Anyone got any better ideas?

Reid.

In writing llvmc, I need to link in the Bytecode reader in order to
extract the "dependent libraries" from the bytecode files. And, bytecode
reader needs vmcore. And, vmcore has a static cl::opt<bool> named
"EnableTiming" for the -time-passes option. This conflicts at runtime
with llvmc's -time-passes option (which it passes through to
sub-tools).

Ok.

So, my solution is to declare the EnableTiming global var in Pass.h,
remove its "static" keyword in Pass.cpp and expose
"Support/CommandLine.h" in Pass.h. This compiles and works fine in all
tools, but its a bit gross to expose CommandLine.h via Pass.h.

Anyone object?

Yes, I do. :slight_smile: Check out how -debug is handled. In particular, the
CommandLine library supports the idea of "external storage", which will
allow you to just put a bool in the header, and have the command line
option set the bool. This is described in the CommandLine documentation
as well.

-Chris

> So, my solution is to declare the EnableTiming global var in Pass.h,
> remove its "static" keyword in Pass.cpp and expose
> "Support/CommandLine.h" in Pass.h. This compiles and works fine in all
> tools, but its a bit gross to expose CommandLine.h via Pass.h.
>
> Anyone object?

Yes, I do. :slight_smile: Check out how -debug is handled. In particular, the
CommandLine library supports the idea of "external storage", which will
allow you to just put a bool in the header, and have the command line
option set the bool. This is described in the CommandLine documentation
as well.

Ah, okay. That makes sense. Will do.