Fix double renaming bug in stack coloring pass

Authored by rsandifo on Jul 5 2013, 7:24 AM.


Fix double renaming bug in stack coloring pass

The stack coloring pass renumbered frame indexes with a loop of the form:

for each frame index FI
  for each instruction I that uses FI
    for each use of FI in I
      rename FI to FI'

This caused problems if an instruction used two frame indexes F0 and F1
and if F0 was renamed to F1 and F1 to F2. The first time we visited the
instruction we changed F0 to F1, then we changed both F1s to F2.

In other words, the problem was that SSRefs recorded which instructions
used an FI, but not which MachineOperands and MachineMemOperands within
that instruction used it.

This is easily fixed for MachineOperands by walking the instructions
once and processing each operand in turn. There's already a loop to
do that for dead store elimination, so it seemed more efficient to
fuse the two at the block level.

MachineMemOperands are more tricky because they can be shared between
instructions. The patch handles them by making SSRefs an array of
MachineMemOperands rather than an array of MachineInstrs. We might end
up processing the same MachineMemOperand twice, but that's OK because
we always know from the SSRefs index what the original frame index was.

llvm-svn: 185703


rsandifoJul 5 2013, 7:24 AM
rG1d0912a47505: We don't need to check for windows' error codes in here.