This is an archive of the discontinued LLVM Phabricator instance.

[LiveIntervals] Fix repairOldRegInRange for simple def cases
ClosedPublic

Authored by foad on Sep 22 2021, 6:05 AM.

Details

Summary

The fix applied in D23303 "LiveIntervalAnalysis: fix a crash in repairOldRegInRange"
was over-zealous. It would bail out when the end of the range to be
repaired was in the middle of the first segment of the live range of
Reg, which was always the case when the range contained a single def of
Reg.

This patch fixes it as suggested by Matthias Braun in post-commit review
on the original patch, and tests it by adding -early-live-intervals to
a selection of existing lit tests that now pass.

(Note that D23303 was originally applied to fix a crash in
SILoadStoreOptimizer, but that is now moot since D23814 updated
SILoadStoreOptimizer to run before scheduling so it no longer has to
update live intervals.)

Diff Detail

Event Timeline

foad created this revision.Sep 22 2021, 6:05 AM
foad requested review of this revision.Sep 22 2021, 6:05 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 22 2021, 6:05 AM
arsenm accepted this revision.Sep 22 2021, 6:41 AM

LGTM. I don't follow how the test changes stress this though

This revision is now accepted and ready to land.Sep 22 2021, 6:41 AM
foad added a comment.EditedSep 22 2021, 6:49 AM

I don't follow how the test changes stress this though

-early-live-intervals means that LiveIntervals is available to TwoAddressInstructionPass, which uses repairIntervalsInRange to update it. Without this patch we hit various assertion and/or verification failures because it doesn't get updated correctly.

I don't follow how the test changes stress this though

-early-live-intervals means that LiveIntervals is available to TwoAddressInstructionPass, which uses repairIntervalsInRange to update it. Without this patch we hit various assertion and/or verification failures because it doesn't get updated correctly.

Can you add a dedicated MIR pass that just runs TwoAddressInstructionPass then?

foad updated this revision to Diff 374500.Sep 23 2021, 3:44 AM

Add a MIR test case.

arsenm accepted this revision.Sep 23 2021, 9:09 AM
This revision was landed with ongoing or failed builds.Sep 23 2021, 9:16 AM
This revision was automatically updated to reflect the committed changes.
foad added a comment.Sep 23 2021, 9:33 AM

This is failing with expensive checks: https://lab.llvm.org/buildbot/#/builders/16/builds/17100

I'vv revert if I can't fix it in the next few minutes.

foad reopened this revision.Sep 23 2021, 9:56 AM
This revision is now accepted and ready to land.Sep 23 2021, 9:56 AM
This revision was automatically updated to reflect the committed changes.