This patch adds support for dynamically aligning stack objects for AArch64 targets.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
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 | 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 | 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. |
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.
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.