[RegAlloc] Keep a copy of live interval for the spilled vregs in HoistSpillHelper

Authored by wmi on Thu, Sep 7, 11:29 AM.



This is to fix PR34502. After rL311401, the live range of spilled vreg will be cleared. HoistSpill need to use the live range of the original vreg before splitting to know the moving range of the spills. The patch saves a copy of live interval for the spilled vreg inside of HoistSpillHelper.

However, it sounds the problem should have been exposed earlier and been more widespread. This bug doesn't happen that often because if the original vreg is spilled, the spill will be generated after its def so no hoisting is needed. Only when the vreg generated from split (i.e., not the original vreg) is spilled, hoisting may be needed, and in that case the live interval of the original vreg will still be there. PR34502 triggered the problem in a very rare way -- after original vreg was spilled, the related valnos vector inside of its live range was released, and it caused some inconsistent state of MergeableSpills map (The map uses valno as its index) and introduced a spill not belonging to the original vreg at all. I didn't successfully create a similar testcase by hand. I am not sure whether we want to add the testcase from PR34502 because it is still a large test after using bugpoint and I believe the check will be in vain quickly since it only happened to trigger the problem.

Diff Detail

wmi created this revision.Thu, Sep 7, 11:29 AM
qcolombet accepted this revision.Fri, Sep 8, 11:04 AM

LGTM with a test case (.mir preferably) from PR34502

This revision is now accepted and ready to land.Fri, Sep 8, 11:04 AM
This revision was automatically updated to reflect the committed changes.