[PATCH] D90219: [SVE] Deal with SVE tuple call arguments correctly when running out of registers

David Sherwood via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 27 04:25:50 PDT 2020


david-arm created this revision.
david-arm added reviewers: sdesmalen, kmclaughlin, rnk.
Herald added subscribers: llvm-commits, psnobl, hiraditya, kristof.beyls, tschuett.
Herald added a reviewer: rengolin.
Herald added a reviewer: efriedma.
Herald added a project: LLVM.
david-arm requested review of this revision.

When passing SVE types as arguments to function calls we can run
out of hardware SVE registers. This is normally fine, since we
switch to an indirect mode where we pass a pointer to a SVE stack
object in a GPR. However, if we switch over part-way through
processing a SVE tuple then part of it will be in registers and
the other part will be on the stack.

I've fixed this by ensuring that:

1. When we don't have enough registers to allocate the whole block we mark any remaining SVE registers temporarily as allocated.
2. We temporarily remove the InConsecutiveRegs flags from the last tuple part argument and reinvoke the autogenerated calling convention handler. Doing this prevents the code from entering an infinite recursion and, in combination with 1), ensures we switch over to the Indirect mode.
3. After allocating a GPR register for the pointer to the tuple we then deallocate any SVE registers we marked as allocated in 1). We also set the InConsecutiveRegs flags back how they were before.
4. I've changed the AArch64ISelLowering LowerCALL and LowerFormalArguments functions to detect the start of a tuple, which involves allocating a single stack object and doing the correct numbers of legal loads and stores.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D90219

Files:
  llvm/include/llvm/CodeGen/CallingConvLower.h
  llvm/include/llvm/CodeGen/TargetCallingConv.h
  llvm/lib/CodeGen/CallingConvLower.cpp
  llvm/lib/Target/AArch64/AArch64CallingConvention.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/test/CodeGen/AArch64/sve-calling-convention-mixed.ll
  llvm/test/CodeGen/AArch64/sve-calling-convention-tuples-broken.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D90219.300939.patch
Type: text/x-patch
Size: 23758 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201027/e1b23ce8/attachment.bin>


More information about the llvm-commits mailing list