[PATCH] D124841: [PowerPC] Stash GPR to VSR if emergency spill slot is not reachable

Nemanja Ivanovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 9 02:01:35 PDT 2022


nemanjai added a comment.

In D124841#3499517 <https://reviews.llvm.org/D124841#3499517>, @efriedma wrote:

> In D124841#3499199 <https://reviews.llvm.org/D124841#3499199>, @nemanjai wrote:
>
>> In D124841#3489679 <https://reviews.llvm.org/D124841#3489679>, @efriedma wrote:
>>
>>> 
>>
>> ...
>
> Are you saying that even though we have a frame pointer, it's impossible to allocate a stack slot close to the frame pointer?  That seems unlikely to me; normal stack layout rules should allow allocating as much space as we need close to the frame pointer.  Depending on how the stack is laid out, I guess it's possible that normal spill slots are never close enough to the frame pointer.  But if we really need it, we could allocate the emergency spill slot next to the callee-saved registers.  (This currently isn't implemented, but shouldn't be complicated.)

To be more precise, I am not saying that this is fundamentally unimplementable but that with the current implementation of how we treat the stack pointer and frame pointer, the frame pointer does not help.
When a function maintains a frame pointer on PowerPC, the frame pointer is equal to the stack pointer until a dynamic allocation changes the stack pointer. After a dynamic allocation, obviously the difference between the two is the (aligned) size of the allocation.
Stack pointer update is the first thing that happens, then the copy to the frame pointer, CSR saves, etc. Given that implementation, if a stack slot is not close enough to the stack pointer, it is not close enough to the frame pointer - and having a frame pointer does not help at all.
Of course, if we changed the implementation to have the frame pointer point to the caller's stack frame, we could address things with a negative offset that accounts for the stack frame size (the static stack frame prior to the dynamic allocation).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124841/new/

https://reviews.llvm.org/D124841



More information about the llvm-commits mailing list