This is an archive of the discontinued LLVM Phabricator instance.

[ARM] Avoid spilling lr with Thumb1 tail calls.
ClosedPublic

Authored by efriedma on Jul 17 2018, 4:49 PM.

Details

Summary

Normally, if any registers are spilled, we prefer to spill lr on Thumb1 so we can fold the "bx lr" into the "pop". However, if there are tail calls involved, restoring lr is expensive, so skip the optimization in that case.

The spill of r7 in the new test also isn't necessary, but that's mostly orthogonal to this patch. (It's the same code in ARMFrameLowering, but it's not related to tail calls.)

Diff Detail

Repository
rL LLVM

Event Timeline

efriedma created this revision.Jul 17 2018, 4:49 PM
chill added inline comments.Jul 18 2018, 6:50 AM
lib/Target/ARM/ARMFrameLowering.cpp
1927 ↗(On Diff #155990)

Instead of traversing all the blocks, would it be possible (or make sense) to set a flag in ARMMachineFunctionInfo, indicating that the function contains tail calls, whenever we create a TC_RETURN in LowerCall,

1927 ↗(On Diff #155990)

Maybe const MachineBasicBlock & ?

efriedma updated this revision to Diff 156186.Jul 18 2018, 5:14 PM

Use MachineFrameInfo::hasTailCall() instead of iterating over the function.

efriedma marked 2 inline comments as done.Jul 18 2018, 5:15 PM
efriedma added inline comments.
lib/Target/ARM/ARMFrameLowering.cpp
1927 ↗(On Diff #155990)

Turns out MachineFrameInfo already has a flag to track this. Patch updated.

efriedma marked 2 inline comments as done.Jul 18 2018, 5:16 PM
chill accepted this revision.Jul 20 2018, 3:28 AM
This revision is now accepted and ready to land.Jul 20 2018, 3:28 AM
This revision was automatically updated to reflect the committed changes.