Odd problem with command line options

I'm linking a program (my ellsif driver) that basically brings in most of the LLVM stuff: bitcode reading, optimizations, linking, and target code generation.

All of a sudden, I'm getting the following when I run:
[~/elsa/ellsif] dev% ./ellsif -v test/ofmt.i test/sieve.i -time-actions -O5
<premain>: CommandLine Error: Argument 'machine-licm' defined more than once!
ellsif: CommandLine Error: Argument 'machine-licm' defined more than once!

It seems like the constructor for this argument is being run twice. ellsif works as expected, but I'd like to figure out what's going wrong.

The link command is:
g++ -o ellsif ellsif.o elsa.o -g -Wall ../elsa/libelsa.a ../elkhound/libelkhound.a ../ast/libast.a ../smbase/libsmbase.a -L/home/rich/llvm-install/lib -lpthread -ldl -lm -lelf -lLLVMLinker -lLLVMArchive -lLLVMipo -lLLVMInstrumentation -lLLVMBitWriter -lLLVMBitReader /home/rich/llvm-install/lib/LLVMMSIL.o /home/rich/llvm-install/lib/LLVMCBackend.o /home/rich/llvm-install/lib/LLVMCellSPU.o /home/rich/llvm-install/lib/LLVMMips.o /home/rich/llvm-install/lib/LLVMARM.o /home/rich/llvm-install/lib/LLVMIA64.o /home/rich/llvm-install/lib/LLVMAlpha.o /home/rich/llvm-install/lib/LLVMPowerPC.o /home/rich/llvm-install/lib/LLVMSparc.o /home/rich/llvm-install/lib/LLVMX86.o -lLLVMSelectionDAG -lLLVMCodeGen -lLLVMScalarOpts -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis -lLLVMTarget -lLLVMCore -lLLVMSupport -lLLVMSystem

Does this sort of thing ring a bell with anyone?

-Rich

I'm linking a program (my ellsif driver) that basically brings in most
of the LLVM stuff: bitcode reading, optimizations, linking, and target
code generation.

All of a sudden, I'm getting the following when I run:
[~/elsa/ellsif] dev% ./ellsif -v test/ofmt.i test/sieve.i -time-actions -O5
<premain>: CommandLine Error: Argument 'machine-licm' defined more than
once!
ellsif: CommandLine Error: Argument 'machine-licm' defined more than once!

It seems like the constructor for this argument is being run twice.
ellsif works as expected, but I'd like to figure out what's going wrong.

This would happen if you're linking libcodegen multiple times.

The link command is:
g++ -o ellsif ellsif.o elsa.o -g -Wall ../elsa/libelsa.a
../elkhound/libelkhound.a ../ast/libast.a ../smbase/libsmbase.a
-L/home/rich/llvm-install/lib -lpthread -ldl -lm -lelf -lLLVMLinker
-lLLVMArchive -lLLVMipo -lLLVMInstrumentation -lLLVMBitWriter
-lLLVMBitReader /home/rich/llvm-install/lib/LLVMMSIL.o
/home/rich/llvm-install/lib/LLVMCBackend.o
/home/rich/llvm-install/lib/LLVMCellSPU.o
/home/rich/llvm-install/lib/LLVMMips.o
/home/rich/llvm-install/lib/LLVMARM.o
/home/rich/llvm-install/lib/LLVMIA64.o
/home/rich/llvm-install/lib/LLVMAlpha.o
/home/rich/llvm-install/lib/LLVMPowerPC.o
/home/rich/llvm-install/lib/LLVMSparc.o
/home/rich/llvm-install/lib/LLVMX86.o -lLLVMSelectionDAG -lLLVMCodeGen
-lLLVMScalarOpts -lLLVMTransformUtils -lLLVMipa -lLLVMAnalysis
-lLLVMTarget -lLLVMCore -lLLVMSupport -lLLVMSystem

This seems pretty reasonable to me. Perhaps your elkhound or elsa archives include some llvm .o files already?

-Chris

I'm linking a program (my ellsif driver) that basically brings in most
of the LLVM stuff: bitcode reading, optimizations, linking, and target
code generation.

All of a sudden, I'm getting the following when I run:
[~/elsa/ellsif] dev% ./ellsif -v test/ofmt.i test/sieve.i -time-actions
-O5
<premain>: CommandLine Error: Argument 'machine-licm' defined more than

once!

ellsif: CommandLine Error: Argument 'machine-licm' defined more than once!

I recently had a similar problem when I wrote a new pass and built it into
opt. This error message is confusing because the code that prints it, in
GetOptionInfo() in lib/Support/CommandLine.cpp:

        cerr << ProgramName << ": CommandLine Error: Argument '"
             << OptionNames[0] << "' defined more than once!\n";

should be printing OptionNames[i], not OptionNames[0].

(Once I had fixed this, it was easy to see what I had done wrong in the pass
I wrote.)

Jay.

Jay Foad wrote:

I'm linking a program (my ellsif driver) that basically brings in most
of the LLVM stuff: bitcode reading, optimizations, linking, and target
code generation.

All of a sudden, I'm getting the following when I run:
[~/elsa/ellsif] dev% ./ellsif -v test/ofmt.i test/sieve.i -time-actions
-O5
<premain>: CommandLine Error: Argument 'machine-licm' defined more than

once!

ellsif: CommandLine Error: Argument 'machine-licm' defined more than once!

I recently had a similar problem when I wrote a new pass and built it into
opt. This error message is confusing because the code that prints it, in
GetOptionInfo() in lib/Support/CommandLine.cpp:

        cerr << ProgramName << ": CommandLine Error: Argument '"
             << OptionNames[0] << "' defined more than once!\n";

should be printing OptionNames[i], not OptionNames[0].

(Once I had fixed this, it was easy to see what I had done wrong in the pass
I wrote.)

Jay.

OK, I finally found my problem. (Which means I took the time to track it down.) At first glance I thought the above patch would work. It didn't.

What it turned out to be is:

./lib/CodeGen/LLVMTargetMachine.cpp:41
EnableLICM("machine-licm",
            cl::init(false), cl::Hidden,
            cl::desc("Perform loop-invariant code motion on machine code"));

and
./lib/CodeGen/MachineLICM.cpp:156:
static RegisterPass<MachineLICM>
X("machine-licm", "Machine Loop Invariant Code Motion");

Both are defining a command line option with the same name. I'm I the only person who links both at the same time? :frowning:

My suggestion: change the name of one or the other. I changed the first one to "enable-machine-licm" since it was hidden.

Does this sound OK?

-Rich

I just fixed this. Try it now.

-bw

Bill Wendling wrote: