A client that uses LLVM for a very large code base has reported an issue where a spill of a CR bit causes a copy into another CR bit in the same CR field to be deleted as it appears to be dead.
The situation is illustrated in the MIR test case attached to this patch, but in a nutshell is the following:
1: $cr5lt = <some defining instr> 2: $cr5gt = COPY $cr1eq 3: SPILL_CRBIT $cr5lt 4: $cr1 = <some cr-field defining instr> 5: SPILL_CRBIT $cr5gt ...
In the current implementation, the COPY at 2 will be deleted since:
- The source of the copy cannot be forwarded to the spill at 5
- It is clobbered by the spill (due to the addition of the KILL instrucntion)
This patch just ensures this no longer happens by not emitting the KILL instruction and achieving what was presumably the purpose of that instruction by:
- Making the CR field that contains the bit being spilled an undef use
- Retaining the kill flag on the spilled bit through an implicit use