This is an archive of the discontinued LLVM Phabricator instance.

[MC] Reset the MCInst in the matcher function before adding opcode/operands.
ClosedPublic

Authored by ab on Dec 15 2014, 5:20 PM.

Details

Summary

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.

Diff Detail

Repository
rL LLVM

Event Timeline

ab updated this revision to Diff 17311.Dec 15 2014, 5:20 PM
ab retitled this revision from to [MC] Reset the MCInst in the matcher function before adding opcode/operands..
ab updated this object.
ab edited the test plan for this revision. (Show Details)
ab added reviewers: rnk, grosbach.
ab added a subscriber: Unknown Object (MLST).

CC the mailing list.

grosbach edited edge metadata.Dec 15 2014, 5:45 PM

Clearing the MCInst seems reasonable. That appears to be the expected behaviour, effectively.

This revision was automatically updated to reflect the committed changes.