For some history here see the commit messages of r199797 and r169060.
The original intent was to fix cases like:
%EAX<def> = COPY %ECX<kill>, %RAX<imp-def>
%RCX<def> = COPY %RAX<kill>
where simply removing the copies would have RCX undefined as in terms of
machine operands only the ECX part of it is defined. The machine
verifier would complain about this so 169060 changed such COPY
instructions into KILL instructions so some super-register imp-defs
would be preserved. In r199797 it was finally decided to always do this
regardless of super-register defs.
But this is wrong! Consider:
R1 = COPY R0
...
R0 = COPY R1
getting changed to:
R1 = KILL R0
...
R0 = KILL R1
It now looks like R0 dies at the first KILL and won't be alive until the
second KILL!
Apparently few people do proper liveness queries this late in the
compiler so this was not noticed. In fact I didn't manage to create a
testcase without other unrelated changes I am working on at the moment.
Anyway the fix is simple: As of r223896 the MachineVerifier allows reads
from partially defined registers, so the whole transforming COPY->KILL
thing is not necessary anymore. This patch also changes a similar (but
more benign case as the def was also always in the src list) case in the
VirtRegRewriter.