On X86, the Intel asm parser tries to match all memory operand sizes when none is explicitly specified. For LEA, which doesn't really have a memory operand (just a pointer one), this results in multiple successful matches, one for each memory size. There's no error because it's same opcode, so really, it's just one match. However, the tablegen'd matcher function adds opcode/operands to the passed MCInst, and this results in multiple duplicated operands.
This patch clears the MCInst in the tablegen'd matcher function. We clear it when the match failed, so there's no expectation of keeping the previous content anyway.
There are other solutions:
- don't reuse a single MCInst in the Intel parser. Easy enough, but feels like a hack.
- special-case LEA to avoid going through all memory operand sizes. I don't like adding a special case, even though LEA is special, so it's reasonable here.