This would print the warning twice:
$ ./bin/llvm-objdump -d /tmp/test.o --mcpu=not-a-cpu
'not-a-cpu' is not a recognized processor for this target (ignoring processor)
'not-a-cpu' is not a recognized processor for this target (ignoring processor)
/tmp/test.o: file format elf64-x86-64
<...>
This is due to warnings printed from InitMCProcessorInfo.
First it calls getFeatures, which warns for an invalid CPU name.
Then it calls getSchedModelForCPU which warns again for the
same reason.
To fix this, don't print a warning in getSchedModelForCPU.
With one exception, this function is only called from
InitMCProcessorInfo so there's already been a warning printed.
The exception is ARMSubtarget::initSubtargetFeatures.
However, this function first calls ParseSubtargetFeatures,
which always calls InitMCProcessorInfo. So again we will
have already printed a warning by the time we call
getSchedModelForCPU.
This actually affects many llvm tools. llvm-objdump, llvm-mc,
llc, lli, llvm-mca and exegis to my knowledge.
However they are all calling the same code so I'm adding
tests just to llvm-objdump which will catch any regression.
--mattr doesn't have this issue and a test is added to
check this.
clang-format not found in user's PATH; not linting file.