This is an archive of the discontinued LLVM Phabricator instance.

[AVR] Fix stack size in functions with a frame pointer
ClosedPublic

Authored by aykevl on Apr 21 2020, 12:03 PM.

Details

Summary

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.

Diff Detail

Event Timeline

aykevl created this revision.Apr 21 2020, 12:03 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 21 2020, 12:03 PM
lenary removed a subscriber: lenary.May 6 2020, 3:53 AM
This revision is now accepted and ready to land.Jun 16 2020, 4:00 AM
This revision was automatically updated to reflect the committed changes.