[PATCH] D78579: [AVR] Fix stack size in functions with a frame pointer

Ayke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 21 12:26:33 PDT 2020


aykevl created this revision.
aykevl added a reviewer: dylanmckay.
Herald added subscribers: luismarques, s.egerton, lenary, Jim, PkmX, simoncook, hiraditya, kristof.beyls.
Herald added a project: LLVM.

This patch fixes a bug in stack save/restore code. Because the frame pointer was saved/restored manually (not by marking it as clobbered) the StackSize variable was not updated accordingly. Most code still worked, but code that tried to load a parameter passed on the stack did not.

This commit fixes this by marking the frame pointer as a callee-clobbered register. This will let it be saved without any effort in prolog/epilog code and will make sure the correct address is calculated for loading parameters that are passed on the stack.

This approach is used by most other targets (such as X86, AArch64 and RISC-V).

---

Note that in two of the tests (calling-conv/c/stack.ll and return.ll) the updated assembly looks a lot better, I think the code was buggy before. I find it hard to say that varargs.ll has been fixed, I'm not exactly sure what the code is doing. That said, this patch does get mulodi4_test.c (in compiler-rt) to pass so it definitely fixes a bug.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78579

Files:
  llvm/lib/Target/AVR/AVRFrameLowering.cpp
  llvm/test/CodeGen/AVR/calling-conv/c/stack.ll
  llvm/test/CodeGen/AVR/return.ll
  llvm/test/CodeGen/AVR/varargs.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78579.259069.patch
Type: text/x-patch
Size: 3846 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200421/207b689d/attachment.bin>


More information about the llvm-commits mailing list