This is found on AIX when using opt-viewer.py.
On AIX, we have a pseudo instruction:
def BCTRL_LWZinto_toc: XLForm_2_ext_and_DForm_1<19, 528, 20, 0, 1, 32, (outs), (ins memri:$src), "bctrl\n\tlwz 2, $src", IIC_BrB, [(PPCbctrl_load_toc iaddr:$src)]>, Requires<[In32BitMode]>;
This pseudo instruction consists of two instructions: bctrl without any explicit operands and lwz with two operands 2 and $src.
getMnemonic introduced in D90040 returns a very strange opcode name for the above instruction, it is bctrl\n\tlwz 2, because AsmWriterInst::AsmWriterInst() treats $ as separator between opcode and operands.
So in the output YAML when generating remarks for asm-printer pass, we get:
- String: "\n" - String: "bctrl\n\tlwz 2, " - String: ': ' - INST_bctrl lwz 2,: '1' - String: "\n"
The invalid YAML will cause opt-viewer.py to work abnormally.
Seems AsmWriterInst::AsmWriterInst() treating $ as the only separator for opcode name and operands is right, because \n or \t are both treated as a normal character in opcode name or operands name, and \n\t exists very common in instruction mnemonic on some targets. so we can not fix the issue there.
And using bctrl as the opcode name for the pseudo instruction BCTRL_LWZinto_toc also follows the current design, the base class for the instruction form indicates:
// Two joined instructions; used to emit two adjacent instructions as one. // The itinerary from the first instruction is used for scheduling and // classification. class I2 { }
Can we just use getToken()?