Compiling for AArch64: CommandLine Error: Option 'aarch64-branch-relax' registered more than once!

Compiling for AArch64: CommandLine Error: Option 'aarch64-branch-relax' registered more than once!

Hi all!

I am trying to run LDC (LLVM-based D compiler) on AArch64. The compiler contains all IR and target specific passes. You can view it as combined llc/opt tool. It uses the same strategy as opt to collect the passes with the NameParser. Like llc, it calls Target.addPassesToEmitFile() to add the target specific passes.

I now get the following error message:

ldc2.exe: CommandLine Error: Option 'aarch64-branch-relax' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options

Reason is that the option 'aarch64-branch-relax' is registered in file lib/Target/AArch64/AArch64BranchRelaxation.cpp and a second time through PassRegistry::registerPass() (because of the use of the NameParser - the pass is also named 'aarch64-branch-relax').

Is this the intended behavior? If yes, what can I do to fix the compiler?

Regards,
Kai

Kai Nacke via llvm-dev <llvm-dev@lists.llvm.org> writes:

Compiling for AArch64: CommandLine Error: Option
'aarch64-branch-relax' registered more than once!

Hi all!

I am trying to run LDC (LLVM-based D compiler) on AArch64. The
compiler contains all IR and target specific passes. You can view it
as combined llc/opt tool. It uses the same strategy as opt to collect
the passes with the NameParser. Like llc, it calls
Target.addPassesToEmitFile() to add the target specific passes.

I now get the following error message:

ldc2.exe: CommandLine Error: Option 'aarch64-branch-relax' registered
more than once!
LLVM ERROR: inconsistency in registered CommandLine options

Reason is that the option 'aarch64-branch-relax' is registered in file
lib/Target/AArch64/AArch64BranchRelaxation.cpp and a second time
through PassRegistry::registerPass() (because of the use of the
NameParser - the pass is also named 'aarch64-branch-relax').

I wouldn't really recommend using the NameParser outside of a testing
tool. The "throw all of the pass names at cl::opt and see what sticks"
thing is pretty specialized to opt and makes for a pretty messy command
line interface for something that does anything other than just running
passes.

That said, the aarch64-branch-relax option in AArch64BranchRelaxation is
a bit silly: it's only useful for *disabling* the pass, despite the
name, and it isn't tested at all. I suspect it's just leftover from when
this pass was first being implemented and can be removed.

Tim: does it make sense to just remove this flag?

Tim: does it make sense to just remove this flag?

Might well do (and a bunch of the other parametrization flags in there
that look like they might even date from when the ISA was up in the
air), but I doubt it would fix the issue. aarch64-branch-relax looks
very suspiciously like it would be at the beginning of any
alphabetical sort of options.

I suspect there's some weird DLL name resolution thing going on and
Kai would just hit the next option if it was removed, but don't really
know what (particularly on Windows).

Cheers.

Tim.

Hi Justin!

Thanks for the answer! I think I will remove this "feature" from ldc. Looks like asking for more trouble if I keep it...

Regards,
Kai

Hi Tim,

there is another failure with 'aarch64-type-promotion'. But I am going to remove this "feature" as Justin has suggested.

Thanks!

Regards,
Kai