[LLVMdev] Infinite loop parsing opt command line options

Alberto Magni alberto.magni86 at gmail.com
Fri May 24 09:38:44 PDT 2013

Hi all,

I am experiencing a problem managing the command line option of a set of
passes in my LLVM project.

Attached you find a toy project the triggers the problem.
The project is made up of two passes: "AnalysisPass" and "TransformPass".
"TransformPass" requires "AnalysisPass" and they both share a common
integer command line option called "-command-line-option"

According to:
the proper way of sharing a cl::opt variable among multiple passes is to
define the variable once and declare it as "explicit" in all the
files of the passes that need it.

To keep the project tidy the two "AnalysisPass" and "TransformPass" are
compiled into two different .so libraries.
The only way I can think of to share the cl::opt variable is to define is
to define it in a separate "Support" static library which is then
linked by both "AnalysisPass" and "TransformPass".

When running "AnalysisPass" loading it with opt all works fine, while
running "TransformPass" opt never returns stuck in an infinite loop.
GDB tells me that opt is trapped somewhere into
llvm::cl::ParseCommandLineOptions, but I am not confident with command line
option management.

Notice that if the cl::opt variable is not used at all in "TransformPass"
everithing runs fine.

Does anybody have an idea on what is going on here ?
Is there a better way of sharing command line options among passes
belonging to different libraries ?

Thank you in advance.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130524/c9118793/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cl_problem.tar.gz
Type: application/x-gzip
Size: 3908 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130524/c9118793/attachment.bin>

More information about the llvm-dev mailing list