[ppc64le] mfspr gpr, ABCD


// 1.s
.abiversion 2
mfspr 8, ABCD
// clang -c -mcpu=power9 -target ppc64le 1.s

The command successfully assembles the source into an object file.

The disassembly shows the instruction emitted:
a6 1a 10 7d: mfspr 8, 112

112 is 0x70.

GNU as throws unsupported relocation error, and doesn't assemble.

This causes problems when a .S is passed to clang for preprocessing
and if the usage of a #define has a typo - clang doesn't catch it.


Hi Amol:

Thanks for reporting this issue.

I believe you are using release build of clang.
If you use assert enabled clang, you should get an assert similar to this:
clang-12: …/llvm/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp:252: int64_t (anonymous namespace)::PPCOperand::getImm() const: Assertion `Kind == Immediate && “Invalid access!”’ failed.

I would say this is somehow a known limitation of current asmparser – the error detection/reporting mechanism is not that user friendly…

I would recommend you open a bugzilla for future enhancement https://bugs.llvm.org/. Thanks.


Jinsong Ji (纪金松), PhD.

XL/LLVM on Power Compiler Development
E-mail: jji@us.ibm.com

graycol.gifAmol via llvm-dev —11/01/2020 09:20:29 AM—Hello, // 1.s