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”
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::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.
cl_problem.tar.gz (3.82 KB)