This is an archive of the discontinued LLVM Phabricator instance.

[IfCvt] Don't use pristine register for counting liveins for predicated instructions.
ClosedPublic

Authored by dmgreen on Nov 6 2020, 12:28 PM.

Details

Summary

The test case here hits machine verifier problems. There are volatile long loads that the results of do not get used, loading into two dead registers. IfCvt will predicate them and as it does will add implicit uses of the predicating registers due to thinking they are live in. As nothing has used the register, the machine verifier disagrees that they are really live and we end up with a failure.

The registers come from Pristine regs that LivePhysRegs counts as live. This patch adds a addLiveInsNoPristines method to be used instead in IfCvt, so that only really live in regs need to be added as implicit operands.

Diff Detail

Event Timeline

dmgreen created this revision.Nov 6 2020, 12:28 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 6 2020, 12:28 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
dmgreen requested review of this revision.Nov 6 2020, 12:28 PM
dmgreen added inline comments.Nov 19 2020, 2:28 AM
llvm/lib/CodeGen/IfConversion.cpp
1518

This is what is really being fixed here, with the Reg being counted as live when it should not be.

efriedma accepted this revision.Jul 10 2021, 1:12 PM

Let me see if I understand what's going on here:

  1. You have a load with a dead result register.
  2. ifcvt doesn't care that it's dead; it treats it like a live result.
  3. Since we're treating the result as live, if the input is live, we need to add it as an implicit use.
  4. ifcvt thinks the pristine register is live, but it really isn't.

I guess this is the right fix, then; LGTM.

That said, ifconversion should probably be fixed at some point to step backwards, rather than forwards. Stepping through a block forwards is sort of deprecated.

This revision is now accepted and ready to land.Jul 10 2021, 1:12 PM