[PATCH] D103622: [RISCV] Avoid scalar outgoing argumetns overwrite vector frame objects.

Hsiangkai Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 3 08:48:55 PDT 2021


HsiangKai created this revision.
HsiangKai added reviewers: craig.topper, frasercrmck, rogfer01, StephenFan.
Herald added subscribers: vkmr, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya.
HsiangKai requested review of this revision.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.

When using FP to access stack objects, the scalable stack objects will
be put at the lower end of the frame. It looks like

  |-------------------|  <-- FP
  | callee-saved regs |
  |-------------------|
  | scalar local vars |
  |-------------------|
  | RVV local vars    |
  |-------------------|  <-- SP

If there are scalar arguments that need to pass through memory and there
are vector objects on the stack using FP to access. The outgoing scalar
arguments will overwrite the vector objects. It looks like

  |-------------------|  <-- FP
  | callee-saved regs |
  |-------------------|
  | scalar local vars |
  |-------------------|         |-------------------|
  | RVV local vars    |         | outgoing args     | <- outgoing arguments
  |-------------------|  <-- SP |-------------------|    overwrite from here.

In this patch, we reserve the stack for the outgoing arguments before
function calls if using FP to access and there are scalable vector frame
objects. It looks like

  |-------------------|  <-- FP
  | callee-saved regs |
  |-------------------|
  | scalar local vars |
  |-------------------|
  | RVV local vars    |
  |-------------------|
  | outgoing args     |
  |-------------------|  <-- SP


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D103622

Files:
  llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
  llvm/test/CodeGen/RISCV/rvv/rvv-out-arguments.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103622.349565.patch
Type: text/x-patch
Size: 3819 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210603/6f9f16a1/attachment.bin>


More information about the llvm-commits mailing list