This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Back up R4 and LR if calling the stack probe function
ClosedPublic

Authored by mstorsjo on May 11 2018, 2:47 PM.

Details

Summary

At this point in determineCalleeSaves, try to get a first estimate of the number of register that will be backed up, to estimate whether a stack probe is going to be needed later or not.

I ran into a case with a function that wouldn't otherwise back up R4 at all, clobbering it with the stack probe call. And apparently one existing test case forgot to back up LR even though it calls the chkstk function within the test.

Diff Detail

Repository
rL LLVM

Event Timeline

mstorsjo created this revision.May 11 2018, 2:47 PM
efriedma added inline comments.May 11 2018, 4:52 PM
lib/Target/ARM/ARMFrameLowering.cpp
1624 ↗(On Diff #146416)

Where does this StackEstimate come from? Could it be factored out into a helper?

mstorsjo added inline comments.May 11 2018, 11:39 PM
lib/Target/ARM/ARMFrameLowering.cpp
1624 ↗(On Diff #146416)

Hmm, unsure how feasible it is... But after looking closer, it seems we don't really need all of it; MFI.estimateStackSize(MF) should in itself be the value needed (or an overestimate of it).

mstorsjo updated this revision to Diff 146463.May 11 2018, 11:40 PM

Simplified the estimate, elaborated the comment a little.

javed.absar added inline comments.May 12 2018, 9:06 AM
lib/Target/ARM/ARMFrameLowering.cpp
1630 ↗(On Diff #146463)

The original comments above (1614-1618) mention R4 but we are dealing with LR as well here now. Would it be better to separate the two?

mstorsjo added inline comments.May 12 2018, 10:09 AM
lib/Target/ARM/ARMFrameLowering.cpp
1630 ↗(On Diff #146463)

Sure, I can do that.

mstorsjo updated this revision to Diff 146473.May 12 2018, 10:10 AM

Separated the blocks, as requested.

Separated the blocks, as requested.

I think you forgot to upload updated patch.

mstorsjo updated this revision to Diff 146551.May 14 2018, 1:50 AM

Actually updated the patch

Separated the blocks, as requested.

I think you forgot to upload updated patch.

Oops, sorry about that. Updated for real now.

javed.absar accepted this revision.May 14 2018, 2:00 AM
This revision is now accepted and ready to land.May 14 2018, 2:00 AM
This revision was automatically updated to reflect the committed changes.