This is an archive of the discontinued LLVM Phabricator instance.

[PowerPC] Fix CR Bit spill pseudo expansion
ClosedPublic

Authored by nemanjai on Dec 21 2018, 4:17 AM.

Details

Summary

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

Diff Detail

Repository
rL LLVM

Event Timeline

nemanjai created this revision.Dec 21 2018, 4:17 AM
hfinkel accepted this revision.Dec 21 2018, 8:38 AM

LGTM. This certainly looks like a better solution; the previous code was indeed trying to make sure that the containing CR field was defined before the mfocrf. Thanks!

This revision is now accepted and ready to land.Dec 21 2018, 8:38 AM
This revision was automatically updated to reflect the committed changes.