This is an archive of the discontinued LLVM Phabricator instance.

[LiveIntervals] Find better anchoring end points when repairing ranges
ClosedPublic

Authored by foad on Sep 21 2021, 9:13 AM.

Details

Summary

r175673 changed repairIntervalsInRange to find anchoring end points for
ranges automatically, but the calculation of Begin included the first
instruction found that already had an index. This patch changes it to
exclude that instruction:

  1. For symmetry, so that the half open range [Begin,End) only includes instructions that do not already have indexes.
  2. As a possible performance improvement, since repairOldRegInRange will scan fewer instructions.
  3. Because repairOldRegInRange hits assertion failures in some cases when it sees a def that already has a live interval.

(3) fixes about ten tests in the CodeGen lit test suite when
-early-live-intervals is forced on.

Diff Detail

Event Timeline

foad created this revision.Sep 21 2021, 9:13 AM
foad requested review of this revision.Sep 21 2021, 9:13 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 21 2021, 9:13 AM
foad updated this revision to Diff 374849.Sep 24 2021, 7:42 AM

Add test.

foad edited the summary of this revision. (Show Details)Sep 24 2021, 7:44 AM
kparzysz added inline comments.Sep 24 2021, 8:16 AM
llvm/lib/CodeGen/LiveIntervals.cpp
1665

I haven't given this code an in-depth look, but the first thing I noticed is that it gets the preceding iterator: how do we know that std::prev(Begin) is actually valid?

foad added inline comments.Sep 24 2021, 8:20 AM
llvm/lib/CodeGen/LiveIntervals.cpp
1665

Because of the Begin != MBB->begin() check!

MatzeB added a comment.Nov 8 2021, 9:10 AM

Change looks good to me, but I would apreciate a better test.

llvm/lib/CodeGen/LiveIntervals.cpp
1663–1668

Would it be realistic to replace these two loops with an assert() and have the callers perform the adjustments only when necessary?

(just as a suggestions, we don't necessarily need to do this as part of this diff)

llvm/test/CodeGen/Hexagon/mulhs.ll
2

Could you create a test in unittests/MI/LiveIntervalTest.cpp that just does a single call to repairIntervalsInRange instead of having this very indirect form of testing?

As @foad mentioned - this patch unblocks D129765 - are we still just waiting on improving test coverage here?

Herald added a project: Restricted Project. · View Herald TranscriptJul 14 2022, 9:17 AM

It might be that we can reduce the mve-sext-masked-load.ll test regression I hit in D129765 into something suited to LiveIntervalTest.cpp ?

foad updated this revision to Diff 445486.Jul 18 2022, 7:23 AM

Add a unit test distilled from test/CodeGen/Thumb2/mve-sext-masked-load.ll

foad marked an inline comment as done.Jul 18 2022, 7:23 AM
MatzeB accepted this revision.Jul 18 2022, 9:32 AM

LGTM

This revision is now accepted and ready to land.Jul 18 2022, 9:32 AM
This revision was landed with ongoing or failed builds.Jul 18 2022, 11:37 AM
This revision was automatically updated to reflect the committed changes.