[PATCH] D156407: [RISCV] Use max pushed register to get pushed register number.

Yeting Kuo via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 27 02:49:37 PDT 2023


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

Previously we used the number of registers needed saved and pushable as the
number of pushed registers. We also use pushed register number to caculate
the stack size. It is not correct because Zcmp pushes registers from $ra to the
max register needed saved and there is no gurantee that the needed saved
registers are a sequenced list from $ra.

There is an example about that. PushPopRegs should be 6 (ra,s0 - s4)= instead of 1.

  ; llc -mtriple=riscv32 -mattr=+zcmp
  define void @foo() {
  entry:
  ; Old:    .cfi_def_cfa_offset 16
  ; New:    .cfi_def_cfa_offset 32
    tail call void asm sideeffect "li s4, 0", "~{s4}"()
    ret void
  }


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156407

Files:
  llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
  llvm/test/CodeGen/RISCV/callee-saved-gprs.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156407.544671.patch
Type: text/x-patch
Size: 7601 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230727/40b2533f/attachment.bin>


More information about the llvm-commits mailing list