This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Use AdjustStackOffset for Callee Saved Registers in PEI::calculateFrameObjectOffsets
ClosedPublic

Authored by DanielMcIntosh-IBM on Feb 28 2022, 10:22 AM.

Details

Summary

Also, changes how the CSR loop is indexed, which should avoid bugs like the one fixed by rG4a57bb5a3b74bdad9b0518009a7d7ac7ca2ac650

Diff Detail

Event Timeline

DanielMcIntosh-IBM requested review of this revision.Feb 28 2022, 10:22 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 28 2022, 10:22 AM

This does look similar at first glance. What's the point of doing this? Why were these paths split in the first place?

DanielMcIntosh-IBM edited the summary of this revision. (Show Details)Feb 28 2022, 10:36 AM

This does look similar at first glance. What's the point of doing this? Why were these paths split in the first place?

They were split when these two loops where first created in rGd31f55c2361068d71f988829d167ce9e24b8f813. I'm not sure why they weren't done as 1 loop like I have here.
It seem like the split has already caused issues with changes to one loop not getting mirrored to the other: rG4a57bb5a3b74bdad9b0518009a7d7ac7ca2ac650 added a MaxCSFrameIndex >= MinCSFrameIndex condition to the else, which was only later mirrored to the other loop by rGea0eec69f16e0f1b00fec413986e4e44f6f627fa.
Not to mention rG6893926b69088eb65053470802e00081234684a7, which hasn't yet been mirrored, and it's not clear if it should (see my comment).

The goal is to generally tidy things up, and prevent similar issues from happening in the future.

llvm/lib/CodeGen/PrologEpilogInserter.cpp
871–873

This was added by rG6893926b69088eb65053470802e00081234684a7, but only to one of the code paths, so I'm not sure if it should be added to both. @arsenm Any memory of whether there was a good reason to only add it to one half?

880–882

For CSRs, the check/update to MaxAlign by AdjustStackOffset should be redundant since rG3b065cdb64b4dcd14c43e8d4e22f2bde680740a7. I'm not sure whether I should do what I have here and assert the expected behaviour, or just pass a dummy value to AdjustStackOffset so the compiler can more easily optimize that bit out when it presumably inlines AdjustStackOffset.

lattner resigned from this revision.Feb 28 2022, 3:32 PM
arsenm accepted this revision.Mar 1 2022, 6:04 PM
This revision is now accepted and ready to land.Mar 1 2022, 6:04 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 1 2022, 6:04 PM
This revision was landed with ongoing or failed builds.Mar 2 2022, 8:41 AM
This revision was automatically updated to reflect the committed changes.