Infinite loop parsing opt command line options

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Infinite loop parsing opt command line options

HariSeldon
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:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2011-January/037722.html
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.

Cheers,
Alberto

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

cl_problem.tar.gz (5K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Infinite loop parsing opt command line options

liuml07
Hi Alberto,

I know nothing about the infinite loop and its root cause. However, I think the order of loading the shared objects (i.e. the two different .so libraries) matters. I once defined a command line option in the firstly loaded shared object, and "extern" it in another shared object file which was loaded afterwards. And it works.

In your case,
1. Define the cl::opt in the AnalysisPass
2. Extern the cl::opt in the TransformPass
3. opt -load libanalysis.so -load libtransform.so -stats -debug foo.bc -o /dev/null

Regards.


On Sat, May 25, 2013 at 12:38 AM, Alberto Magni <[hidden email]> wrote:
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:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2011-January/037722.html
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.

Cheers,
Alberto

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




--
Mingliang LIU (刘明亮 in Chinese)

PACMAN Group,  Dept. of Computer Science & Technology
Tsinghua University, Beijing 100084, China
Email: [hidden email]

_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev