This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Add support for dynamically aligning stack objects
ClosedPublic

Authored by kristof.beyls on Apr 7 2015, 11:36 AM.

Details

Summary

This patch adds support for dynamically aligning stack objects for AArch64 targets.

Diff Detail

Repository
rL LLVM

Event Timeline

kristof.beyls retitled this revision from to [AArch64] Add support for dynamically aligning stack objects.
kristof.beyls updated this object.
kristof.beyls edited the test plan for this revision. (Show Details)
kristof.beyls added a reviewer: t.p.northover.
kristof.beyls set the repository for this revision to rL LLVM.
kristof.beyls added a subscriber: Unknown Object (MLST).
t.p.northover edited edge metadata.Apr 7 2015, 12:22 PM

Hi Kristof,

Thanks for working on this, it's a good feature to have. Just a couple of suggestions:

lib/Target/AArch64/AArch64FrameLowering.cpp
367 ↗(On Diff #23355)

What do we do if NumBytes == 0 but we need realignment? I'm OK with not handling that case (Clang won't produce an "alignstack=BIG" attribute for AArch64), but we should probably assert that it can't happen somewhere.

374 ↗(On Diff #23355)

Any particular reason for using BFI here? I'd have thought AND would be the more natural choice: it only has one register dependency (even if the XZR is a false dependency here) and can directly write to SP (avoiding the copy).

Slightly more difficult to encode, of course.

Either way, could we assert that ScratchSPReg is not SP here: neither instruction permits SP as an input, but refactoring could easily mess up that invariant later on.

Oh, and particularly thanks for those comments at the top! Very useful.

kristof.beyls edited edge metadata.
kristof.beyls removed rL LLVM as the repository for this revision.

Thanks for the quick review and nice catches.
It's indeed better to use AND instead of BFI; the patch now does this. It also makes some of the logic a bit simpler - but doesn't reduce the number of instructions needed when a base pointer is also needed, which is when there are both VLAs and dynamically aligned local variables.
I've also added the asserts you indicated - indeed they are good to have.

t.p.northover accepted this revision.Apr 8 2015, 11:32 AM
t.p.northover edited edge metadata.

Thanks for the updated patch Kristof. I think this is fine now.

Tim.

This revision is now accepted and ready to land.Apr 8 2015, 11:32 AM
This revision was automatically updated to reflect the committed changes.