Closed dylanmckay closed 6 years ago
Adding testing flag because we have to write our machine code tests around this bug, and will have to update them all once it is fixed.
This is a bug in LLVM.
In AVRGenAsmWriter.inc
, the instruction alias printer does not handle duplicate operands that are constrained to be identical. The symptom of this is that whenever there is an alias of an instruction with a repeated operand, the alias will never be resolved.
Here is my private branch with half a fix.
I have opened up LLVM bug 23925
This seems to be fixed since r318895
tst Rd
maps toand Rd, Rd
clr Rd
maps toeor Rd, Rd
ser Rd
maps toldi Rd, 0xff
The first two instructions, when printed, are not written as
tst Rd
orclr Rd
- they are printed asand Rd, Rd
andeor Rd, Rd
. The last instruction correctly maps toser Rd
when printed.The only difference between the two is that
ser Rd
only hasRd
once in the pattern, whereastst
andclr
haveRd
repeated in the pattern.It appears that instruction aliases with repeated operands in the patterns do not work correctly with regards to the instruction printer. A brief debugging shows that inside
printAliasInstr
inAVRGenAsmWriter.inc
(generated by TableGen) checks if theMCInst
has2
operands (presumably a brief sanity check), before it checks whether the instruction corresponds totst
orclr
- however, the instruction always contains3
operands -Rd
repeated three times, causing the conditional to never be true, and the alias to not be printed.In
utils/TableGen
, theCodeGenInstAlias
class holds information about an alias - the string pattern, the instruction that is being aliased, and the arguments to the instruction. TableGen isn't adding duplicate operands from theCodeGenInstruction Result
into theResultOperands
field in theCodeGenInstAlias
if it is a duplicate.