This patch sets the 'KeepReg' bit for any tied registers during the PrescanInstruction() phase of the dependency breaking algorithm. It then checks those 'KeepReg' bits during the ScanInstruction() phase to avoid changing any tied registers. For more details, please see comments in:
http://llvm.org/bugs/show_bug.cgi?id=20020
The existing code also uses the 'Classes' variable as a marker for registers that shouldn't be changed (by setting the value to -1). If someone can explain why we need two data structures to mark unusable regs, I'd love to understand that.
I added two FIXME comments for code that I think can be removed by using register iterators that include self. I don't want to include those code changes with this patch, however, to keep things as small as possible.
The test case is larger than I'd like, but I don't know how to reduce it further and still produce the failing asm.
Can you put an assert inside the existing check that the tied registers are in KeepRegs?