This is an archive of the discontinued LLVM Phabricator instance.

CodeGen: Assert that liveness is up to date when reading block live-ins.
ClosedPublic

Authored by MatzeB on Dec 7 2016, 6:24 PM.

Details

Summary

Add an assert that checks whether liveins are up to date before
they are used.

  • Do not print liveins into .mir files anymore in situations where they are out of date anyway.
  • The assert in the RegisterScavenger is superseded by the new one in livein_begin().
  • Skip parts of the liveness updating logic in IfConversion.cpp when liveness isn't tracked anymore (just enough to avoid hitting the new assert()).

Diff Detail

Repository
rL LLVM

Event Timeline

MatzeB updated this revision to Diff 80708.Dec 7 2016, 6:24 PM
MatzeB retitled this revision from to CodeGen: Do not compute liveins when trackLivenessAfterRegalloc() is false.
MatzeB updated this object.
MatzeB added a reviewer: qcolombet.
MatzeB set the repository for this revision to rL LLVM.
MatzeB added a subscriber: llvm-commits.
MatzeB added a comment.Dec 7 2016, 6:39 PM

I just realized that I only tested AArch64 for this. Most of the other targets run into the newly introduced assert :-( So this needs further work before it can land.

MatzeB updated this revision to Diff 80935.Dec 9 2016, 12:41 PM
MatzeB retitled this revision from CodeGen: Do not compute liveins when trackLivenessAfterRegalloc() is false to CodeGen: Assert that liveness is up to date when reading block live-ins..
MatzeB updated this object.

Turns out not computing live-in lists when trackLivenessAfterRegAlloc() is too aggressive for todays LLVM (for example MachineLICM which is setup as part of TargetPassConfig::addOptimizedRegAlloc() requires up-to-date live-in lists.

In any case adding an assert when querying the live-in list should avoid bad usage.

I updated the patch accordingly.

MatzeB updated this revision to Diff 80936.Dec 9 2016, 12:47 PM
MatzeB removed rL LLVM as the repository for this revision.

bring back accidentally removed comment.

qcolombet edited edge metadata.Dec 19 2016, 6:41 PM

Turns out not computing live-in lists when trackLivenessAfterRegAlloc() is too aggressive for todays LLVM (for example MachineLICM which is setup as part of TargetPassConfig::addOptimizedRegAlloc() requires up-to-date live-in lists.

Could you elaborate on the implications?
I stopped reviewing the patch when you put this comment but I didn't see any change on MachineLICM for instance, so I thought something bigger was still coming, but given the ping, it seems I missed the purpose of the comment x).

lib/CodeGen/RegisterScavenging.cpp
54 ↗(On Diff #80936)

Removing that assert seems strange.
I was thinking this is okay because it will be checked anyway when we use MachineBasicBlock::liveins(), but was this your intent?

MatzeB added a comment.Jan 2 2017, 5:41 AM

Turns out not computing live-in lists when trackLivenessAfterRegAlloc() is too aggressive for todays LLVM (for example MachineLICM which is setup as part of TargetPassConfig::addOptimizedRegAlloc() requires up-to-date live-in lists.

Could you elaborate on the implications?
I stopped reviewing the patch when you put this comment but I didn't see any change on MachineLICM for instance, so I thought something bigger was still coming, but given the ping, it seems I missed the purpose of the comment x).

That comment was just about what changed in the updated version of the patch: My previous patch was more aggressive and disabled all live-in information if tracksLivenessAfterRegAlloc() was false. Turned out that doesn't work yet, so I left that for another day/patch.

This patch now just adds an assert and fixes instance where the block live-in lists are used in situations in which they are possibly out of date.

MatzeB added inline comments.Jan 2 2017, 5:43 AM
lib/CodeGen/RegisterScavenging.cpp
54 ↗(On Diff #80936)

Yes, this assert() is redundant now because we have one in MachineBasicBlock::livein_begin() anyway.

qcolombet accepted this revision.Jan 3 2017, 5:35 PM
qcolombet edited edge metadata.

Thanks for the clarifications Matthias.

LGTM.

Cheers,
-Quentin

This revision is now accepted and ready to land.Jan 3 2017, 5:35 PM
This revision was automatically updated to reflect the committed changes.